mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-08-03 08:36:03 -04:00
Define the concept of a 'federation Query'; creating API for making and handling Queries on the Federation's increasingly-inaccurately-named ReplicationLayer
This commit is contained in:
parent
1ddae5f40b
commit
827de7cee9
3 changed files with 113 additions and 0 deletions
|
@ -180,6 +180,19 @@ class TransportLayer(object):
|
|||
|
||||
defer.returnValue((code, response))
|
||||
|
||||
@defer.inlineCallbacks
|
||||
@log_function
|
||||
def make_query(self, destination, query_type, args):
|
||||
path = PREFIX + "/query/%s" % query_type
|
||||
|
||||
response = yield self.client.get_json(
|
||||
destination=destination,
|
||||
path=path,
|
||||
args=args
|
||||
)
|
||||
|
||||
defer.returnValue(response)
|
||||
|
||||
@log_function
|
||||
def register_received_handler(self, handler):
|
||||
""" Register a handler that will be fired when we receive data.
|
||||
|
@ -251,6 +264,15 @@ class TransportLayer(object):
|
|||
lambda request, context: handler.on_context_pdus_request(context)
|
||||
)
|
||||
|
||||
# This is when we receive a server-server Query
|
||||
self.server.register_path(
|
||||
"GET",
|
||||
re.compile("^" + PREFIX + "/query/([^/]*)$"),
|
||||
lambda request, query_type: handler.on_query_request(
|
||||
query_type, {k: v[0] for k, v in request.args.items()}
|
||||
)
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
@log_function
|
||||
def _on_send_request(self, request, transaction_id):
|
||||
|
@ -456,3 +478,6 @@ class TransportRequestHandler(object):
|
|||
of what went wrong.
|
||||
"""
|
||||
pass
|
||||
|
||||
def on_query_request(self):
|
||||
""" Called on a GET /query/<query_type> request. """
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue