Counterpoint.EventRegistry (counterpoint v0.1.0)

Copy Markdown View Source

ETS-backed registry that maps event type strings to their modules.

Started automatically by Counterpoint.Supervisor. Pass the list of event modules via the events: option so they are registered at startup and can be deserialized when reading from the store.

Example (via supervisor)

Counterpoint.Supervisor.start_link(
  store: [name: :my_store, namespace: "my_app"],
  events: [MyApp.Events.OrderPlaced, MyApp.Events.OrderCancelled]
)

Manual registration (testing / hot-reloading)

Counterpoint.EventRegistry.register_all([MyApp.Events.OrderPlaced])

Summary

Functions

Returns a specification to start this module under a supervisor.

Look up the module for a given type string.

Register a list of event modules so they can be deserialized by type string.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

lookup(type_string)

Look up the module for a given type string.

Returns {:ok, module} or {:error, :unknown_type}.

register_all(modules)

Register a list of event modules so they can be deserialized by type string.