Skip to content

Commit

Permalink
rename the messaging_template in the service (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-dot authored Oct 16, 2024
1 parent cd91f0f commit ac0fee8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/blueapi/service/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def worker() -> TaskWorker:


@lru_cache
def messaging_template() -> StompClient | None:
def stomp_client() -> StompClient | None:
stomp_config = config().stomp
if stomp_config is not None:
template = StompClient.for_broker(
Expand Down Expand Up @@ -83,16 +83,16 @@ def setup(config: ApplicationConfig) -> None:

logging.basicConfig(level=config.logging.level)
worker()
messaging_template()
stomp_client()


def teardown() -> None:
worker().stop()
if (template := messaging_template()) is not None:
if (template := stomp_client()) is not None:
template.disconnect()
context.cache_clear()
worker.cache_clear()
messaging_template.cache_clear()
stomp_client.cache_clear()


def _publish_event_streams(
Expand All @@ -104,7 +104,7 @@ def _publish_event_streams(

def _publish_event_stream(stream: EventStream, destination: DestinationBase) -> None:
def forward_message(event: Any, correlation_id: str | None) -> None:
if (template := messaging_template()) is not None:
if (template := stomp_client()) is not None:
template.send(destination, event, None, correlation_id=correlation_id)

stream.subscribe(forward_message)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/service/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,4 @@ def test_stomp_config(template: StompClient):
"blueapi.service.interface.StompClient.for_broker", return_value=template
):
interface.set_config(ApplicationConfig(stomp=StompConfig()))
assert interface.messaging_template() is not None
assert interface.stomp_client() is not None

0 comments on commit ac0fee8

Please sign in to comment.