# `Redis.Sentinel`
[🔗](https://github.com/joshrotenberg/redis_ex/blob/v0.7.1/lib/redis/sentinel/sentinel.ex#L1)

Sentinel-aware Redis connection.

Queries sentinels to discover the current primary or replica, then
maintains a connection. On disconnection, re-queries sentinels to
find the (possibly new) primary.

## Usage

    {:ok, conn} = Redis.Sentinel.start_link(
      sentinels: [{"sentinel1", 26379}, {"sentinel2", 26379}],
      group: "mymaster",
      role: :primary,
      password: "secret"
    )

    # Use like a normal connection — failover is transparent
    {:ok, "OK"} = Redis.Sentinel.command(conn, ["SET", "key", "value"])

## Options

  * `:sentinels` - list of sentinel addresses as `{host, port}` tuples or `"host:port"` strings (required)
  * `:group` - sentinel group name (required)
  * `:role` - `:primary` or `:replica` (default: `:primary`)
  * `:password` - password for the Redis server (not the sentinel)
  * `:sentinel_password` - password for sentinel connections
  * `:username` - username for the Redis server
  * `:database` - database number
  * `:timeout` - connection timeout ms (default: 5_000)
  * `:sentinel_timeout` - sentinel query timeout ms (default: 500)
  * `:name` - GenServer name registration
  * `:protocol` - `:resp3` or `:resp2` (default: `:resp3`)

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `command`

```elixir
@spec command(GenServer.server(), [String.t()], keyword()) ::
  {:ok, term()} | {:error, term()}
```

Sends a command through the sentinel-managed connection.

# `info`

```elixir
@spec info(GenServer.server()) :: map()
```

Returns info about the current connection.

# `pipeline`

```elixir
@spec pipeline(GenServer.server(), [[String.t()]], keyword()) ::
  {:ok, [term()]} | {:error, term()}
```

# `start_link`

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

# `stop`

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

# `transaction`

```elixir
@spec transaction(GenServer.server(), [[String.t()]], keyword()) ::
  {:ok, [term()]} | {:error, term()}
```

---

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