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

Add helper base class for generating new replication endpoints #3632

Merged
merged 9 commits into from
Aug 9, 2018
6 changes: 4 additions & 2 deletions synapse/replication/http/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def send_request(**kwargs):
if e.code != 504 or not cls.RETRY_ON_TIMEOUT:
raise

logger.warn("send_federation_events_to_master request timed out")
logger.warn("%s request timed out", cls.NAME)

# If we timed out we probably don't need to worry about backing
# off too much, but lets just wait a little anyway.
Expand Down Expand Up @@ -190,7 +190,9 @@ def register(self, http_server):
http_server.register_paths(method, [pattern], handler)

def _cached_handler(self, request, txn_id, **kwargs):
"""Wraps `_handle_request` the responses should be cached.
"""Called on new incoming requests when caching is enabled. Checks
if their is a cached response for the request and returns that,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

their

otherwise calls `_handle_request` and caches its response.
"""
# We just use the txn_id here, but we probably also want to use the
# other PATH_ARGS as well.
Expand Down
36 changes: 36 additions & 0 deletions synapse/replication/http/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@

class ReplicationRemoteJoinRestServlet(ReplicationEndpoint):
"""Does a remote join for the given user to the given room
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please could you document the format of the URI - particularly since it seems to be changing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ditto below)


Request format:

POST /_synapse/replication/remote_join/:room_id/:user_id

{
"requester": ...,
"remote_room_hosts": [...],
"content": { ... }
}
"""

NAME = "remote_join"
Expand Down Expand Up @@ -85,6 +95,15 @@ def _handle_request(self, request, room_id, user_id):

class ReplicationRemoteRejectInviteRestServlet(ReplicationEndpoint):
"""Rejects the invite for the user and room.

Request format:

POST /_synapse/replication/remote_reject_invite/:room_id/:user_id

{
"requester": ...,
"remote_room_hosts": [...],
}
"""

NAME = "remote_reject_invite"
Expand Down Expand Up @@ -153,6 +172,17 @@ def _handle_request(self, request, room_id, user_id):

class ReplicationRegister3PIDGuestRestServlet(ReplicationEndpoint):
"""Gets/creates a guest account for given 3PID.

Request format:

POST /_synapse/replication/get_or_register_3pid_guest/

{
"requester": ...,
"medium": ...,
"address": ...,
"inviter_user_id": ...
}
"""

NAME = "get_or_register_3pid_guest"
Expand Down Expand Up @@ -206,6 +236,12 @@ def _handle_request(self, request):

class ReplicationUserJoinedLeftRoomRestServlet(ReplicationEndpoint):
"""Notifies that a user has joined or left the room

Request format:

POST /_synapse/replication/membership_change/:room_id/:user_id/:change

{}
"""

NAME = "membership_change"
Expand Down