DiamondLightSource / DiamondLightSource/bluesky-stomp

Easy support for bluesky callbacks

Open
#14 6 comments 0 reactions 1 assignee Claimed by @rtuck99 View on GitHub
enhancement
Dominant language
Python
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

As a user I want to run bluesky callbacks (of the form `(name: str, doc: dict) -> None`) in a separate process using a stomp broker as the intermediary for the documents.

Also requested by @olliesilvester to aid in the Hyperion migration.

## Possible Solution

I imagine we want something that looks a bit like this

```python
import bluesky.plans as bp
from bluesky.run_engine import RunEngine
from dodal.i22 import saxs, waxs
from ophyd_async.core import DeviceCollector
from bluesky_stomp.router import DocumentRouter
from bluesky.callbacks.best_effort import BestEffortCallback

username = input("Please enter your username")
password = input("Please enter your password", password=True)
auth = BasicAuthentication(username=username, password=password)

# We assume there is a RunEngine out there somewhere publishing documents to topic "foo"
router = DocumentRouter(host="localhost", port=61613, destination=Topic(name="foo"), auth=auth)
bec = BestEffortCallback()
router.subscribe(bec)

input("Press enter to finish")
```

Where we have a wrapper around `StompClient` that takes a `RunEngine` callback of the form `(name, doc) -> None`, bundles it into a dictionary of the form `{"name": name, "doc": doc}` and sends it to the desired destination.

## Acceptance Criteria
- There is an importable helper class/method for handling documents coming out of the message bus
- This can easily be hooked up to existing bluesky callbacks such as `BestEffortCallback`
- It can authenticate against the broker with a username and password
- Tests
- Example in README

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.