diff options
author | Erik Johnston <erik@matrix.org> | 2020-04-22 13:07:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-22 13:07:41 +0100 |
commit | 51f7eaf908a84fcaf231899e2bf1beae14ae72c0 (patch) | |
tree | e7e14016f42d021542d1703415cf6e06804310eb /synapse/replication/tcp/commands.py | |
parent | Reduce logging verbosity of URL cache cleanup. (#7295) (diff) | |
download | synapse-51f7eaf908a84fcaf231899e2bf1beae14ae72c0.tar.xz |
Add ability to run replication protocol over redis. (#7040)
This is configured via the `redis` config options.
Diffstat (limited to 'synapse/replication/tcp/commands.py')
-rw-r--r-- | synapse/replication/tcp/commands.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/synapse/replication/tcp/commands.py b/synapse/replication/tcp/commands.py index 5ec89d0fb8..5002efe6a0 100644 --- a/synapse/replication/tcp/commands.py +++ b/synapse/replication/tcp/commands.py @@ -454,3 +454,21 @@ VALID_CLIENT_COMMANDS = ( ErrorCommand.NAME, RemoteServerUpCommand.NAME, ) + + +def parse_command_from_line(line: str) -> Command: + """Parses a command from a received line. + + Line should already be stripped of whitespace and be checked if blank. + """ + + idx = line.index(" ") + if idx >= 0: + cmd_name = line[:idx] + rest_of_line = line[idx + 1 :] + else: + cmd_name = line + rest_of_line = "" + + cmd_cls = COMMAND_MAP[cmd_name] + return cmd_cls.from_line(rest_of_line) |