# `Kombu.Transport.Redis.Channel`
[🔗](https://github.com/hacktobeer/kombu/blob/v0.1.0/lib/kombu/transport/redis/channel.ex#L1)

Redis virtual channel (`kombu.transport.redis.Channel`).

Implements Kombu's Redis broker protocol:
- Priority queues (`priority_steps = [0, 3, 6, 9]`) with `` (`<<6, 22>>`) separator
- Exchange binding sets (`_kombu.binding.<exchange>`, `_kombu.binding_permanent.<exchange>`, `_kombu.binding_deadlines`)
- Fanout Pub/Sub (`/{db}.<exchange>`)
- Ack emulation via `Kombu.Transport.Redis.QoS` (`unacked`, `unacked_index`, `unacked_mutex`)
- Queue expiration (`x-expires`) and binding deadline refresh/sweep Lua scripts
- Batched publishing via `Kombu.Transport.Redis.PublishBatch`

# `t`

```elixir
@type t() :: %Kombu.Transport.Redis.Channel{
  ack_emulation: term(),
  active_fanout_queues: term(),
  active_queues: term(),
  auto_delete_queues: term(),
  binding_expiry_refreshed_at: term(),
  bindings_swept_at: term(),
  body_encoding: term(),
  broker_state: term(),
  channel_id: term(),
  client: term(),
  closed: term(),
  consumers: term(),
  deadletter_queue: term(),
  do_restore: term(),
  expires: term(),
  fanout_buffer: term(),
  fanout_patterns: term(),
  fanout_prefix: term(),
  fanout_queues: term(),
  fanout_to_queue: term(),
  global_keyprefix: term(),
  keyprefix_binding_deadlines: term(),
  keyprefix_binding_permanent: term(),
  keyprefix_fanout: term(),
  keyprefix_queue: term(),
  max_priorities: term(),
  no_ack_consumers: term(),
  priority_steps: term(),
  qos: term(),
  queue_cycle: term(),
  queue_order_strategy: term(),
  sep: term(),
  virtual_host: term()
}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `default_priority_steps`

# `do_restore_message`

Restores a raw message payload to its destination queue(s) in Redis, marking `redelivered = true`.
If `leftmost` is true, pushes via `LPUSH`; otherwise pushes via `RPUSH` (matching `redis.py`).

# `exchange_type`

Determines the exchange type for `exchange`.

# `expire_commands_for_queue`

Returns `PEXPIRE` commands for all priority keys of `queue` if `x-expires` is set.

# `get`

Pops a message from `queue` by checking priority buckets `[0, 3, 6, 9]` in order via `RPOP`.
Returns `{:ok, raw_message_map}` or `:empty`.

# `get_publish_topic`

Returns the Pub/Sub topic for publishing to a fanout `exchange`.

# `get_subscribe_topic`

Returns the Pub/Sub topic pattern for subscribing to fanout `queue`.

# `get_table`

Fetches the routing table `[{routing_key, pattern, queue}]` for `exchange` from Redis.

# `has_queue?`

Checks whether any priority list for `queue` exists in Redis (`EXISTS` pipeline).

# `lookup`

Looks up matching destination queues for `(exchange, routing_key)` by querying Redis `SMEMBERS`.

# `lookup_with_table`

Looks up matching destination queues for `(exchange, routing_key)` given `table`.

# `message_priority_for_queue`

Computes the clamped message priority for `queue`, respecting `x-max-priority` if configured.

# `new_state`

Creates a `%Kombu.Transport.Redis.Channel{}` state struct directly (useful in unit tests).

# `priority`

```elixir
@spec priority(t() | [integer()], integer()) :: integer()
```

Maps an integer priority `n` (`0..9`) to its priority step bucket (`[0, 3, 6, 9]`).

# `purge`

Purges all priority lists for `queue` (`LLEN` + `DEL` pipeline) and returns the number of removed messages.

# `put`

Pushes `message` (raw map) into `queue` at its priority bucket in Redis.

# `put_fanout`

Publishes a fanout `message` (raw map) to the Redis Pub/Sub topic for `exchange`.

# `q_for_pri`

```elixir
@spec q_for_pri(t() | [integer()], String.t(), integer()) :: String.t()
```

Returns the Redis list key for `queue` at priority `pri`.
Priority 0 uses `queue`; non-zero step uses `"#{queue}\x06\x16#{step}"`.

# `sep`

# `size`

Returns the total length of `queue` across all priority steps (`LLEN` pipeline).

# `start_link`

# `unq_for_pri`

```elixir
@spec unq_for_pri(String.t()) :: String.t()
```

Strips any `<pri>` suffix from a Redis queue key.

---

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