Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Refactor/generalize outbound requests from an extension #57

Open
dbwiddis opened this issue Sep 25, 2023 · 0 comments
Open

[FEATURE] Refactor/generalize outbound requests from an extension #57

dbwiddis opened this issue Sep 25, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@dbwiddis
Copy link
Member

Is your feature request related to a problem?

While most extension functionality is receiving requests and sending responses, some functionality sends requests the other way. The request/response pairs are matched by their request_id fields, which requires handling them in a particular order. The below sequence would have to be repeated for any other outbound requests.

# Create the request, this gets us an auto-increment request id
register_request = OutboundMessageRequest(
thread_context=request.thread_context_struct,
features=request.features,
message=RegisterRestActionsRequest(self.extension.name, self.extension.named_routes),
version=request.version,
action="internal:discovery/registerrestactions",
is_handshake=False,
is_compress=False,
)
# Register response handler to handle this request ID invoking this class's send()
register_response_handler = RegisterRestActionsResponseHandler(self)
self.response_handlers.register(register_request.request_id, register_response_handler)
# Now send the request
return register_response_handler.send(register_request)

We have to:

  1. Create a request
  2. Get the id from step 1
  3. Pass the id as a key to the response handler registry, and a handler as a value
  4. Finally send the request from step 1

What solution would you like?

A single class where I can pass the request from step 1 and the handler from step 3 as arguments, and it handles extracting the key and actually sending the request.

What alternatives have you considered?

Add the functionality to the Request Handler abstract class, or add it to another abstract parent class.

Do you have any additional context?

https://www.explainxkcd.com/wiki/index.php/353:_Python

@dbwiddis dbwiddis added enhancement New feature or request untriaged Issues that require attention from the maintainers. labels Sep 25, 2023
@dblock dblock removed the untriaged Issues that require attention from the maintainers. label Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants