Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Adding support for redis logical db #15034

Merged
merged 6 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/15034.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow Synapse to use a specific Redis [logical database](https://redis.io/commands/select/) in worker-mode deployments.
1 change: 1 addition & 0 deletions contrib/docker_compose_workers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ redis:
enabled: true
host: redis
port: 6379
# dbid: <redis_logical_db_id>
# password: <secret_password>
```

Expand Down
4 changes: 4 additions & 0 deletions docs/usage/configuration/config_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3927,6 +3927,9 @@ This setting has the following sub-options:
* `host` and `port`: Optional host and port to use to connect to redis. Defaults to
localhost and 6379
* `password`: Optional password if configured on the Redis instance.
* `dbid`: Optional redis dbid if needs to connect to specific redis logical db.
999lakhisidhu marked this conversation as resolved.
Show resolved Hide resolved

_Added in Synapse 1.78.0._

Example configuration:
```yaml
Expand All @@ -3935,6 +3938,7 @@ redis:
host: localhost
port: 6379
password: <secret_password>
dbid: <dbid>
```
---
## Individual worker configuration
Expand Down
1 change: 1 addition & 0 deletions synapse/config/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:

self.redis_host = redis_config.get("host", "localhost")
self.redis_port = redis_config.get("port", 6379)
self.redis_dbid = redis_config.get("dbid", None)
self.redis_password = redis_config.get("password")
1 change: 1 addition & 0 deletions synapse/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ def get_outbound_redis_connection(self) -> "ConnectionHandler":
hs=self,
host=self.config.redis.redis_host,
port=self.config.redis.redis_port,
dbid=self.config.redis.redis_dbid,
password=self.config.redis.redis_password,
reconnect=True,
)
Expand Down