# `Rheo.Backend.Mongo`
[🔗](https://github.com/thanos/rheo/blob/v1.0.0/lib/rheo/backend/mongo.ex#L3)

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`.

# `child_spec`

```elixir
@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`

```elixir
@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`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
