# `Kombu.ConsumerServer`
[🔗](https://github.com/hacktobeer/kombu/blob/v0.1.0/lib/kombu/consumer_server.ex#L1)

OTP GenServer behavior and base implementation mirroring Python Kombu's
`ConsumerMixin` and `ConsumerProducerMixin`.

Provides:
- Connection management with automatic reconnection and backoff
- Lifecycle hooks (`on_connection_error`, `on_connection_revived`, `on_consume_ready`, `on_consume_end`)
- Integration with `Kombu.Consumer` and `Kombu.Producer`
- Safe message consumption in a supervised worker loop

# `state`

```elixir
@type state() :: term()
```

# `get_consumers`

```elixir
@callback get_consumers(channel :: term(), state()) ::
  {[Kombu.Consumer.t()], state()} | [Kombu.Consumer.t()]
```

# `handle_message`
*optional* 

```elixir
@callback handle_message(body :: term(), message :: Kombu.Message.t(), state()) ::
  {:noreply, state()} | {:stop, reason :: term(), state()}
```

# `init`

```elixir
@callback init(args :: term()) :: {:ok, state()} | {:stop, reason :: term()}
```

# `on_connection_error`
*optional* 

```elixir
@callback on_connection_error(error :: term(), interval :: float(), state()) :: state()
```

# `on_connection_revived`
*optional* 

```elixir
@callback on_connection_revived(state()) :: state()
```

# `on_consume_end`
*optional* 

```elixir
@callback on_consume_end(state()) :: state()
```

# `on_consume_ready`
*optional* 

```elixir
@callback on_consume_ready(consumers :: [Kombu.Consumer.t()], state()) :: state()
```

# `on_decode_error`
*optional* 

```elixir
@callback on_decode_error(message :: Kombu.Message.t(), error :: term(), state()) ::
  state()
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `publish`

```elixir
@spec publish(GenServer.server(), term(), keyword()) :: term()
```

Publishes a message using the server's producer (if producer is enabled).

# `start_link`

```elixir
@spec start_link(module(), term(), keyword()) :: GenServer.on_start()
```

# `stop`

```elixir
@spec stop(GenServer.server(), term(), timeout()) :: :ok
```

Stops the consumer server gracefully.

---

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