mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
separate cbc proxy into separate clients
this is a pretty big and convoluted refactor unfortunately.
Previously:
There was one global `cbc_proxy_client` object in apps. This class has
the information about how to invoke the bt-ee lambda, and handles all
calls to lambda. This includes calls to the canary too (which is a
separate lambda).
The future:
There's one global `cbc_proxy_client`. This knows about the different
provider functions and lambdas, and you'll need to ask this client for a
proxy for your chosen provider. call cbc_proxy_client.get_proxy('ee')`
and it'll return you a proxy that knows what ee's lambda function is,
how to transform any content in a way that is exclusive to ee, and in
future how to parse any response from ee.
The present:
I also cleaned up some duplicate tests.
I'm really not sure about the names of some of these variables - in
particular `cbc_proxy_client` isn't a client - it's more of a java style
factory, where you call a function on it to get the client of your
choice.
This commit is contained in:
@@ -39,8 +39,10 @@ def send_broadcast_provider_message(broadcast_event_id, provider):
|
||||
for polygon in broadcast_event.transmitted_areas["simple_polygons"]
|
||||
]
|
||||
|
||||
cbc_proxy_provider_client = cbc_proxy_client.get_proxy(provider)
|
||||
|
||||
if broadcast_event.message_type == BroadcastEventMessageType.ALERT:
|
||||
cbc_proxy_client.create_and_send_broadcast(
|
||||
cbc_proxy_provider_client.create_and_send_broadcast(
|
||||
identifier=str(broadcast_provider_message.id),
|
||||
headline="GOV.UK Notify Broadcast",
|
||||
description=broadcast_event.transmitted_content['body'],
|
||||
@@ -49,7 +51,7 @@ def send_broadcast_provider_message(broadcast_event_id, provider):
|
||||
expires=broadcast_event.transmitted_finishes_at_as_cap_datetime_string,
|
||||
)
|
||||
elif broadcast_event.message_type == BroadcastEventMessageType.UPDATE:
|
||||
cbc_proxy_client.update_and_send_broadcast(
|
||||
cbc_proxy_provider_client.update_and_send_broadcast(
|
||||
identifier=str(broadcast_provider_message.id),
|
||||
headline="GOV.UK Notify Broadcast",
|
||||
description=broadcast_event.transmitted_content['body'],
|
||||
@@ -59,7 +61,7 @@ def send_broadcast_provider_message(broadcast_event_id, provider):
|
||||
expires=broadcast_event.transmitted_finishes_at_as_cap_datetime_string,
|
||||
)
|
||||
elif broadcast_event.message_type == BroadcastEventMessageType.CANCEL:
|
||||
cbc_proxy_client.cancel_broadcast(
|
||||
cbc_proxy_provider_client.cancel_broadcast(
|
||||
identifier=str(broadcast_provider_message.id),
|
||||
headline="GOV.UK Notify Broadcast",
|
||||
description=broadcast_event.transmitted_content['body'],
|
||||
@@ -88,4 +90,4 @@ def trigger_link_test(provider):
|
||||
identifier = str(uuid.uuid4())
|
||||
message = f"Sending a link test to CBC proxy for provider {provider} with ID {identifier}"
|
||||
current_app.logger.info(message)
|
||||
cbc_proxy_client.send_link_test(identifier)
|
||||
cbc_proxy_client.get_proxy(provider).send_link_test(identifier)
|
||||
|
||||
@@ -301,7 +301,7 @@ def send_canary_to_cbc_proxy():
|
||||
identifier = str(uuid.uuid4())
|
||||
message = f"Sending a canary message to CBC proxy with ID {identifier}"
|
||||
current_app.logger.info(message)
|
||||
cbc_proxy_client.send_canary(identifier)
|
||||
cbc_proxy_client.get_proxy('canary').send_canary(identifier)
|
||||
|
||||
|
||||
@notify_celery.task(name='trigger-link-tests')
|
||||
|
||||
Reference in New Issue
Block a user