Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
6870fc49
Commit
6870fc49
authored
6 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Move connecting logic into ClientReplicationStreamProtocol
parent
09fc34c9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/replication/tcp/client.py
+0
-18
0 additions, 18 deletions
synapse/replication/tcp/client.py
synapse/replication/tcp/protocol.py
+17
-0
17 additions, 0 deletions
synapse/replication/tcp/protocol.py
with
17 additions
and
18 deletions
synapse/replication/tcp/client.py
+
0
−
18
View file @
6870fc49
...
...
@@ -89,11 +89,6 @@ class ReplicationClientHandler(object):
# Used for tests.
self
.
awaiting_syncs
=
{}
# Set of stream names that have been subscribe to, but haven't yet
# caught up with. This is used to track when the client has been fully
# connected to the remote.
self
.
streams_connecting
=
None
# The factory used to create connections.
self
.
factory
=
None
...
...
@@ -122,12 +117,6 @@ class ReplicationClientHandler(object):
Can be overriden in subclasses to handle more.
"""
# When we get a `POSITION` command it means we've finished getting
# missing updates for the given stream, and are now up to date.
self
.
streams_connecting
.
discard
(
stream_name
)
if
not
self
.
streams_connecting
:
self
.
finished_connecting
()
return
self
.
store
.
process_replication_rows
(
stream_name
,
token
,
[])
def
on_sync
(
self
,
data
):
...
...
@@ -154,9 +143,6 @@ class ReplicationClientHandler(object):
elif
room_account_data
:
args
[
"
account_data
"
]
=
room_account_data
# Record which streams we're in the process of subscribing to
self
.
streams_connecting
=
set
(
args
.
keys
())
return
args
def
get_currently_syncing_users
(
self
):
...
...
@@ -222,10 +208,6 @@ class ReplicationClientHandler(object):
connection
.
send_command
(
cmd
)
self
.
pending_commands
=
[]
# This will happen if we don't actually subscribe to any streams
if
not
self
.
streams_connecting
:
self
.
finished_connecting
()
def
finished_connecting
(
self
):
"""
Called when we have successfully subscribed and caught up to all
streams we
'
re interested in.
...
...
This diff is collapsed.
Click to expand it.
synapse/replication/tcp/protocol.py
+
17
−
0
View file @
6870fc49
...
...
@@ -511,6 +511,11 @@ class ClientReplicationStreamProtocol(BaseReplicationStreamProtocol):
self
.
server_name
=
server_name
self
.
handler
=
handler
# Set of stream names that have been subscribe to, but haven't yet
# caught up with. This is used to track when the client has been fully
# connected to the remote.
self
.
streams_connecting
=
set
()
# Map of stream to batched updates. See RdataCommand for info on how
# batching works.
self
.
pending_batches
=
{}
...
...
@@ -533,6 +538,10 @@ class ClientReplicationStreamProtocol(BaseReplicationStreamProtocol):
# We've now finished connecting to so inform the client handler
self
.
handler
.
update_connection
(
self
)
# This will happen if we don't actually subscribe to any streams
if
not
self
.
streams_connecting
:
self
.
handler
.
finished_connecting
()
def
on_SERVER
(
self
,
cmd
):
if
cmd
.
data
!=
self
.
server_name
:
logger
.
error
(
"
[%s] Connected to wrong remote: %r
"
,
self
.
id
(),
cmd
.
data
)
...
...
@@ -562,6 +571,12 @@ class ClientReplicationStreamProtocol(BaseReplicationStreamProtocol):
return
self
.
handler
.
on_rdata
(
stream_name
,
cmd
.
token
,
rows
)
def
on_POSITION
(
self
,
cmd
):
# When we get a `POSITION` command it means we've finished getting
# missing updates for the given stream, and are now up to date.
self
.
streams_connecting
.
discard
(
cmd
.
stream_name
)
if
not
self
.
streams_connecting
:
self
.
handler
.
finished_connecting
()
return
self
.
handler
.
on_position
(
cmd
.
stream_name
,
cmd
.
token
)
def
on_SYNC
(
self
,
cmd
):
...
...
@@ -578,6 +593,8 @@ class ClientReplicationStreamProtocol(BaseReplicationStreamProtocol):
self
.
id
(),
stream_name
,
token
)
self
.
streams_connecting
.
add
(
stream_name
)
self
.
send_command
(
ReplicateCommand
(
stream_name
,
token
))
def
on_connection_closed
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment