Module: Iodine::PubSub

Defined in:
lib/iodine/pubsub.rb,
ext/iodine/iodine_pubsub.c

Overview

Iodine is equiped with an internal pub/sub service that allows improved resource management from a deployment perspective.

As described by [Wikipedia](en.wikipedia.org/wiki/Publish–subscribe_pattern):

publish

The common paradigm, which is implemented by pub/sub services like Redis, is for a “client” to “subscribe” to one or more “channels”. Messages are streamed to these “channels” by different “publishers” (the application / other clients) and are broadcasted to the “clients” through their “subscription”.

Iodine’s approach it to offload pub/sub resource costs from the pub/sub service (which is usually expensive to scale) onto the application layer.

For example, the default (‘nil`) pub/sub Engine implements an internal pub/sub service that manages subscriptions (clients and channels) throughout an Iodine process cluster without any need to connect to an external pub/sub service.

If Iodine was runninng with 8 processes and 16 threads per process, a publishing in process A will be delivered to subscribers in process B.

In addition, by inheriting the Engine class, it’s easy to create pub/sub engines that connect to this underlying pub/sub service. This means that Iodine will call the engine’s ‘subscribe` method only once per channel and once messages arrive, Iodine will distribute the messages to all the subscribed clients.

Defined Under Namespace

Classes: Engine, RedisEngine

Constant Summary collapse

CLUSTER =

This is the (currently) default pub/sub engine. It will distribute messages to all subscribers in the process cluster.

engine_in_c
SINGLE_PROCESS =

This is a single process pub/sub engine. It will distribute messages to all subscribers sharing the same process.

engine_in_c