View Source EchoPubSub.Worker (EchoPubSub v0.2.0)

Receives batches from the producers on other nodes and broadcasts them to this node's subscribers, one worker per pool group.

The worker joins the group's :pg group, which is how producers find it. It replies :ok to a batch only after broadcasting it locally; the producer moves that node's read cursor only on that reply.

It also remembers which producer nodes have registered with it, in an ETS table owned by the adapter supervisor so the record survives a worker restart. A {:register, node} from a producer it already knows means that producer lost this node's cursor, so the worker sends {:cursor_expired, node} to every local topic. {:resume, node} only records the producer, and {:expired, node} always sends the notice.

Summary

Functions

Returns a specification to start this module under a supervisor.

The registered name of the group's worker.

Names the table of producer nodes registered with this group's worker.

Starts the worker for group, broadcasting batches to the name PubSub server.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec name(atom()) :: atom()

The registered name of the group's worker.

Link to this function

registrations_table(group)

View Source
@spec registrations_table(atom()) :: atom()

Names the table of producer nodes registered with this group's worker.

The adapter supervisor owns the table, so a restarted worker still knows which producers registered before and can tell them apart from new ones.

@spec start_link({atom(), atom()}) :: GenServer.on_start()

Starts the worker for group, broadcasting batches to the name PubSub server.