Raxol.Workflow.Checkpoint.Saver.Dets (Raxol v2.6.0)

View Source

DETS-backed Raxol.Workflow.Checkpoint.Saver adapter.

Wraps a :dets table in a single named GenServer so the file stays open for the lifetime of the server. Checkpoints survive BEAM restarts as long as the same file path is used.

Lifecycle

{:ok, _pid} =
  Raxol.Workflow.Checkpoint.Saver.Dets.start_link(
    name: MyApp.WorkflowCheckpoints,
    file: "/var/lib/raxol/workflow.dets"
  )

# later
Raxol.Workflow.Checkpoint.Saver.Dets.stop(MyApp.WorkflowCheckpoints)

Compile a graph with this saver:

Graph.compile(graph,
  saver: {Raxol.Workflow.Checkpoint.Saver.Dets,
          %{name: MyApp.WorkflowCheckpoints}})

The behaviour callbacks dispatch a GenServer.call/3 against the configured name and let the server own the DETS file handle.

Append-only contract

Same as the Ets adapter: writing a (thread_id, step) pair that already exists is a no-op. The server uses :dets.insert_new/2 internally.

Not for very-high-throughput writers

A single GenServer call is the serialization point for all writes and reads. Workflows that emit hundreds of checkpoints per second per node should use the Postgrex adapter (follow-up PR) or a custom Saver targeting a partitioned store.

Summary

Functions

Returns a specification to start this module under a supervisor.

Start the DETS server.

Stop the server and close the underlying DETS file.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

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

Start the DETS server.

Required opts:

  • :name -- atom used as the process name and the DETS table id
  • :file -- path to the DETS file (created if missing)

stop(server)

@spec stop(GenServer.server()) :: :ok

Stop the server and close the underlying DETS file.