DEV Community

loading...
Cover image for Introducing `Rocketman`, a gem to help you do Pub/Sub code in Pure Ruby. No Rails needed!

Introducing `Rocketman`, a gem to help you do Pub/Sub code in Pure Ruby. No Rails needed!

edisonywh profile image Edison Yap ・1 min read

Publishing my second Ruby gem here with the community, introducing Rocketman!

Description

Rocketman is a gem that introduces Pub-Sub mechanism within Ruby code.

As with all Pub-Sub mechanism, this greatly decouples your upstream producer and downstream consumer, allowing for scalability, and easier refactor when you decide to move Pub-Sub to a separate service.

Rocketman also works without Rails.

GitHub logo edisonywh / rocketman

🚀 Rocketman help build event-based/pub-sub code in Ruby

Rocketman

rocketman yes, I know it says Starman on the image

🎶 And I think it's gonna be a long long time 'Till touch down brings me round again to find 🎶

Rocketman is a gem that introduces Pub-Sub mechanism within your Ruby code.

The main goal of Rocketman is not to replace proper message buses like Redis PubSub/Kafka, but rather be a stepping stone. You can read more about the rationale behind the project down below.

As with all Pub-Sub mechanism, this greatly decouples your upstream producer and downstream consumer, allowing for scalability, and easier refactor when you decide to move Pub-Sub to a separate service.

Rocketman also works without Rails.

Installation

Add this line to your application's Gemfile:

gem 'rocketman'
Enter fullscreen mode Exit fullscreen mode

And then execute:

$ bundle

Or install it yourself as:

$ gem install rocketman

Usage

Rocketman exposes two module, Rocketman::Producer and Rocketman::Consumer. They do exactly as what their…

Usage

emitting events look as easy as this:

emit :hello, payload: {"one" => 1, "two" => 2}
Enter fullscreen mode Exit fullscreen mode

and listening for events look like this:

on_event :hello do |payload|
  puts payload
end
Enter fullscreen mode Exit fullscreen mode

There’s more information on the Usage section and Roadmap if you’re interested in the project, otherwise, feel free to comment here too!

Discussion (0)

pic
Editor guide