Listex.List (Listex v0.1.0)

View Source

The process that holds one list.

Everything interesting about this module follows from one fact: a GenServer has a mailbox, and a mailbox is a total order. Operations from any number of concurrent editors are applied one at a time in the order they arrive, and that order is the conflict policy — no operational transform, no vector clocks, no merge. Two editors updating the same item both succeed; the one whose message arrives second is the one you end up looking at.

You normally reach this through Listex, but the process is a plain GenServer and can be started and supervised on its own.

Options

  • :id — the list id; generated when absent.
  • :contents — a list of terms (or Listex.Item structs when you want to choose the ids) to spawn the process from.
  • :idle_timeout — milliseconds without a client message before the process shuts down. Defaults to 5 minutes. :infinity disables it.
  • :name — a name to register under, or false for an unnamed process. Defaults to Listex.Registry.via(id).

Idle shutdown

Client messages (operations, reads, subscribes) push the deadline back; internal traffic such as a subscriber going down does not. On expiry every subscriber is sent {:listex, list_id, {:closed, :idle}} and the process exits :normal. State lives in memory only — it goes with the process.

Summary

Functions

Starts a list process. See the module docs for options.

Types

mode()

@type mode() :: :full | :updates

op()

@type op() ::
  {:insert, term(), keyword()}
  | {:update, Listex.ID.t(), term()}
  | {:move, Listex.ID.t(), Listex.ID.t() | :start | :end}
  | {:delete, Listex.ID.t()}

Functions

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts a list process. See the module docs for options.