Rheo.Backend.Mongo (rheo v1.0.0)

Copy Markdown View Source

MongoDB implementation of Rheo.Backend.

Requires {:mongodb_driver, "~> 1.5"} in your dependencies.

Prefer the Rheo facade for application code. The opaque handle is the Mongo process name (or pid) started via child_spec/1.

Collections

  • streams — stream registry and sequence allocator
  • events — immutable event log
  • groups — consumer group registry and materialization cursor
  • deliveries — per (stream, group, event_id) lease / ACK / DLQ state

Supervision example

children = [
  {Rheo, name: MyRheo, backend: {Rheo.Backend.Mongo, url: "mongodb://localhost:27017/rheo"}}
]

Callback semantics are documented on Rheo.Backend.

Summary

Functions

Child spec for the Mongo connection process (backend handle).

Default Mongo handle name for the Rheo instance.

Functions

child_spec(opts)

@spec child_spec(keyword()) :: Supervisor.child_spec()

Child spec for the Mongo connection process (backend handle).

Arguments

  • opts — keyword options:
    • :url — Mongo URL (default: Application.get_env(:rheo, :mongo_url))
    • :name — handle / process name (default: default_handle/0)
    • :pool_size — pool size (default 5)
    • plus other options accepted by Mongo.start_link/1

Examples

iex> spec = Rheo.Backend.Mongo.child_spec(url: "mongodb://localhost:27017/rheo", name: :demo_mongo)
iex> {spec.id, elem(spec.start, 0), Keyword.fetch!(elem(spec.start, 2) |> hd(), :name)}
{{Mongo, :demo_mongo}, Mongo, :demo_mongo}

Returns

A supervisor child spec map. Does not raise; missing :mongo_url when :url is omitted raises ArgumentError via Application.fetch_env!/2 at start time.

default_handle()

@spec default_handle() :: atom()

Default Mongo handle name for the Rheo instance.

Examples

iex> Rheo.Backend.Mongo.default_handle()
Rheo.Mongo

Returns

A process name atom (default Rheo.Mongo).