Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 1.05 KB

README.md

File metadata and controls

29 lines (22 loc) · 1.05 KB

Lattice Observer

A reusable Elixir library for monitoring a lattice and deriving observed state.

Usage

The lattice observer is a GenServer supervisor that operates a process tree responsible for reacting to events from a lattice and computing derived state from those events.

First, you'll want to create a Gnat.ConnectionSupervisor with a given name, for example:

 Supervisor.child_spec(
        {Gnat.ConnectionSupervisor, nats_connection_options},
        id: :lattice_connection_supervisor
      ),

With a running Gnat/NATS connection supervisor, you can then start the NATS lattice observer:

{:ok, lattice} = NatsObserver.start_link(
    %{
        supervised_connection: :lattice_connection_supervisor,
        module: MyApp.LatticeWatcher
        lattice_prefix: "default"
    })

The module argument is the name of a module that must implement the LatticeObserver.Observer behavior. This module's state_changed(state) function will be invoked when state changes, etc.

For more information, see the hex documentation.