Merged
Conversation
00d97ef to
ffa500e
Compare
c7c3612 to
8ac83d5
Compare
0f06c45 to
8dd93d7
Compare
33676d7 to
8755cf3
Compare
|
|
||
| Communication uses Azure Relay which relies on websockets. | ||
|
|
||
| The `Relay` model defines the connection details for a Gateway. A shared access key should be stored in Azure Key Vault and the `shared_access_key_variable_name` field should be set to the name of the ENV var referencing the secret. (Note that keyvault secrets are hyphen delimited, but ENV vars are underscore delimited). |
Contributor
There was a problem hiding this comment.
should we get the key in manage_breast_screening/config/.env.tpl?
| def _create_action(self) -> GatewayAction: | ||
| def _create_action(self) -> GatewayAction | None: | ||
| """Create and persist the gateway action.""" | ||
| relay = Relay.objects.filter(provider=self.appointment.provider).first() |
Contributor
There was a problem hiding this comment.
maybe RelayService could expose get_relay_for(provider) or some such
Contributor
Author
There was a problem hiding this comment.
Good idea, have added Relay.for_provider class method
9ddc2b7 to
c41c486
Compare
RelayService provides transport for GatewayAction payloads. It starts a thread which sends payloads to the gateway and exits, cleaning up the asyncio process used to communicate via Azure Relay websockets. The Relay database model holds connection details for each of our gateway connections.
Also remove update_status method as it won't be used.
This commit removes the need to run any async code in a new thread. This has the benefit of better database connection cleanup, safer execution of the websocket async code etc. We will be addressing the failure scenarios for the websocket connection and retrying.
c41c486 to
995414b
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Description
We send the modality worklist item to the relevant Gateway listener via Azure Relay and this transmission of data should occur out of the request cycle via Relay websocket.
In order to effectively background the process of communicating with the Gateway we need a separate process.
This PR adds a few things which allow this communication to happen:
Jira link
https://nhsd-jira.digital.nhs.uk/browse/DTOSS-12148
Review notes
I've opted for running a finite length event loop
in a separate threadin order to "fire and forget" the gateway action payload via the relay connection because long lived websockets require a loop.The acknowledgement from the gateway updates a record in the db.
This PR does not deal with retrying failed actions. We will review how this might be done with the UCD team.
Review checklist