CoderRing.GenRing (CoderRing v0.2.3) View Source

GenServer wrapper for a CoderRing.

Keeping memo state in memory with a process means some database reads can be skipped. State is, however, always synced to the database so it can be restored properly on app restart.

Take care to only have one GenRing proc running for a ring at any given time. For instance, if running on a multi-server deployment, use Erlang's clustered mode and a global process registry like Horde to guarantee no more than one proc for a ring across the cluster.

When running on a single server, it should be sufficient to use GenRing.


Create a module in your application:

defmodule MyApp.CoderRing do
  use CoderRing.GenRing, otp_app: :my_app

Then, add it to your application supervisor:

def start(_type, _args) do
  children =
    ] ++

  opts = [...]
  {:ok, pid} = Supervisor.start_link(children, opts)