LangEx.Checkpointer.Postgres (LangEx v0.11.3)

Copy Markdown View Source

PostgreSQL-backed checkpointer using Ecto.

Assumes the lang_ex_checkpoints table has been created via LangEx.Migration. See LangEx.Migration for setup instructions.

State is encoded with LangEx.Checkpoint.Serializer, so structs, atoms, and tuples survive the round-trip exactly.

Config

The :repo key must point to an Ecto.Repo module:

config = [repo: MyApp.Repo, thread_id: "thread-1"]
LangEx.Checkpointer.Postgres.save(config, checkpoint)

Summary

Functions

Deletes checkpoints created before the given DateTime, across all threads. Returns {:ok, deleted_count}. Run periodically (e.g. from a scheduled job) to enforce a retention window

Functions

prune(config, opts)

@spec prune(keyword(), keyword()) :: {:ok, non_neg_integer()}

Deletes checkpoints created before the given DateTime, across all threads. Returns {:ok, deleted_count}. Run periodically (e.g. from a scheduled job) to enforce a retention window:

LangEx.Checkpointer.Postgres.prune([repo: MyApp.Repo],
  older_than: DateTime.add(DateTime.utc_now(), -30, :day)
)