# `Sourced.Operation`
[🔗](https://gitlab.com/dimakula/sourced/-/blob/0.2.0/lib/sourced/operation.ex#L1)

The value threaded through an event store's middleware pipeline.

Analogous to a `Plug.Conn`: each `Sourced.Middleware` receives an
operation, may transform it on the way in (e.g. encode `events`, resolve query
types in `opts`), calls the next layer, and may transform `result` on the way
out (e.g. decode stored events). The innermost terminal calls the adapter and
populates `result`.

# `action`

```elixir
@type action() :: :append | :query | :subscribe | :notify
```

# `append_result`

```elixir
@type append_result() ::
  {:ok, non_neg_integer()}
  | {:error, Sourced.EventStore.Behaviour.append_error() | term()}
```

The result an append operation carries once the terminal has run.

# `query_result`

```elixir
@type query_result() ::
  {:ok, Sourced.EventStore.Behaviour.query_result()} | {:error, term()}
```

The result a query operation carries once the terminal has run.

# `t`

```elixir
@type t() :: %Sourced.Operation{
  action: action(),
  events: [Sourced.EventStore.Behaviour.event() | struct()] | nil,
  opts: keyword(),
  result: {:ok, term()} | {:error, term()} | nil,
  store: Sourced.EventStore.Behaviour.store()
}
```

---

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