Remove unused 'stream' param of REPLICATE and update docs

pull/7024/head
Erik Johnston 2020-03-23 14:56:22 +00:00
parent 4f2a803c66
commit a2070a2c4e
5 changed files with 21 additions and 48 deletions

View File

@ -14,16 +14,16 @@ example flow would be (where '>' indicates master to worker and
'<' worker to master flows): '<' worker to master flows):
> SERVER example.com > SERVER example.com
< REPLICATE events 53 < REPLICATE
> POSITION events 53
> RDATA events 54 ["$foo1:bar.com", ...] > RDATA events 54 ["$foo1:bar.com", ...]
> RDATA events 55 ["$foo4:bar.com", ...] > RDATA events 55 ["$foo4:bar.com", ...]
The example shows the server accepting a new connection and sending its The example shows the server accepting a new connection and sending its identity
identity with the `SERVER` command, followed by the client asking to with the `SERVER` command, followed by the client server to respond with the
subscribe to the `events` stream from the token `53`. The server then position of all streams. The server then periodically sends `RDATA` commands
periodically sends `RDATA` commands which have the format which have the format `RDATA <stream_name> <token> <row>`, where the format of
`RDATA <stream_name> <token> <row>`, where the format of `<row>` is `<row>` is defined by the individual streams.
defined by the individual streams.
Error reporting happens by either the client or server sending an ERROR Error reporting happens by either the client or server sending an ERROR
command, and usually the connection will be closed. command, and usually the connection will be closed.
@ -32,9 +32,6 @@ Since the protocol is a simple line based, its possible to manually
connect to the server using a tool like netcat. A few things should be connect to the server using a tool like netcat. A few things should be
noted when manually using the protocol: noted when manually using the protocol:
- When subscribing to a stream using `REPLICATE`, the special token
`NOW` can be used to get all future updates. The special stream name
`ALL` can be used with `NOW` to subscribe to all available streams.
- The federation stream is only available if federation sending has - The federation stream is only available if federation sending has
been disabled on the main process. been disabled on the main process.
- The server will only time connections out that have sent a `PING` - The server will only time connections out that have sent a `PING`
@ -91,9 +88,7 @@ The client:
- Sends a `NAME` command, allowing the server to associate a human - Sends a `NAME` command, allowing the server to associate a human
friendly name with the connection. This is optional. friendly name with the connection. This is optional.
- Sends a `PING` as above - Sends a `PING` as above
- For each stream the client wishes to subscribe to it sends a - Sends a `REPLICATE` to get the current position of all streams.
`REPLICATE` with the `stream_name` and token it wants to subscribe
from.
- On receipt of a `SERVER` command, checks that the server name - On receipt of a `SERVER` command, checks that the server name
matches the expected server name. matches the expected server name.
@ -140,9 +135,7 @@ the wire:
> PING 1490197665618 > PING 1490197665618
< NAME synapse.app.appservice < NAME synapse.app.appservice
< PING 1490197665618 < PING 1490197665618
< REPLICATE events 1 < REPLICATE
< REPLICATE backfill 1
< REPLICATE caches 1
> POSITION events 1 > POSITION events 1
> POSITION backfill 1 > POSITION backfill 1
> POSITION caches 1 > POSITION caches 1
@ -199,20 +192,7 @@ client (C):
#### REPLICATE (C) #### REPLICATE (C)
Asks the server to replicate a given stream. The syntax is: Asks the server for the current position of all streams.
```
REPLICATE <stream_name> <token>
```
Where `<token>` may be either:
* a numeric stream_id to stream updates since (exclusive)
* `NOW` to stream all subsequent updates.
The `<stream_name>` is the name of a replication stream to subscribe
to (see [here](../synapse/replication/tcp/streams/_base.py) for a list
of streams). It can also be `ALL` to subscribe to all known streams,
in which case the `<token>` must be set to `NOW`.
#### USER_SYNC (C) #### USER_SYNC (C)

View File

@ -179,29 +179,24 @@ class NameCommand(Command):
class ReplicateCommand(Command): class ReplicateCommand(Command):
"""Sent by the client to subscribe to the stream. """Sent by the client to subscribe to streams.
Format:: Format::
REPLICATE <stream_name> REPLICATE
The <stream_name> can be "ALL" to subscribe to all known streams
""" """
NAME = "REPLICATE" NAME = "REPLICATE"
def __init__(self, stream_name): def __init__(self):
self.stream_name = stream_name pass
@classmethod @classmethod
def from_line(cls, line): def from_line(cls, line):
return cls(line) return cls()
def to_line(self): def to_line(self):
return self.stream_name return ""
def get_logcontext_id(self):
return "REPLICATE-" + self.stream_name
class UserSyncCommand(Command): class UserSyncCommand(Command):

View File

@ -35,9 +35,7 @@ indicate which side is sending, these are *not* included on the wire::
> PING 1490197665618 > PING 1490197665618
< NAME synapse.app.appservice < NAME synapse.app.appservice
< PING 1490197665618 < PING 1490197665618
< REPLICATE events 1 < REPLICATE
< REPLICATE backfill 1
< REPLICATE caches 1
> POSITION events 1 > POSITION events 1
> POSITION backfill 1 > POSITION backfill 1
> POSITION caches 1 > POSITION caches 1
@ -662,7 +660,7 @@ class ClientReplicationStreamProtocol(BaseReplicationStreamProtocol):
""" """
logger.info("[%s] Subscribing to replication streams", self.id()) logger.info("[%s] Subscribing to replication streams", self.id())
self.send_command(ReplicateCommand("ALL")) self.send_command(ReplicateCommand())
def on_connection_closed(self): def on_connection_closed(self):
BaseReplicationStreamProtocol.on_connection_closed(self) BaseReplicationStreamProtocol.on_connection_closed(self)

View File

@ -69,9 +69,9 @@ class BaseStreamTestCase(unittest.HomeserverTestCase):
self.streamer.on_notifier_poke() self.streamer.on_notifier_poke()
self.pump(0.1) self.pump(0.1)
def replicate_stream(self, stream, token="NOW"): def replicate_stream(self):
"""Make the client end a REPLICATE command to set up a subscription to a stream""" """Make the client end a REPLICATE command to set up a subscription to a stream"""
self.client.send_command(ReplicateCommand(stream)) self.client.send_command(ReplicateCommand())
class TestReplicationClientHandler(object): class TestReplicationClientHandler(object):

View File

@ -24,7 +24,7 @@ class ReceiptsStreamTestCase(BaseStreamTestCase):
self.reconnect() self.reconnect()
# make the client subscribe to the receipts stream # make the client subscribe to the receipts stream
self.replicate_stream("receipts", "NOW") self.replicate_stream()
self.test_handler.streams.add("receipts") self.test_handler.streams.add("receipts")
# tell the master to send a new receipt # tell the master to send a new receipt