Arc.Subscription (cratis_arc v0.1.0)

Copy Markdown View Source

One live subscription to an observable query.

A subscription is a process under the application's dynamic supervisor. It runs the query, sends the owner {:arc_query_result, id, %Arc.QueryResult{}}, and sends another every time a watched read model changes or a topic is notified. It monitors the owner and ends with it.

It uses restart: :temporary: a failing subscription ends instead of restarting and failing again in a loop; the client resubscribes.

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts a subscription. spec is a map with :owner, :id, :descriptor, :query, :args, :ctx and :opts. Requires the application to be started.

Stops a subscription.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start(app, spec)

@spec start(module(), map()) :: {:ok, pid()} | {:error, term()}

Starts a subscription. spec is a map with :owner, :id, :descriptor, :query, :args, :ctx and :opts. Requires the application to be started.

stop(pid)

@spec stop(pid()) :: :ok

Stops a subscription.