DiamondLightSource / DiamondLightSource/bluesky-stomp
Easy publishing mechanism from `RunEngine`
- Dominant language
- Python
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
As a user I would like to connect my `RunEngine` to the message bus with minimal boilerplate.
## Possible Solution
We probably want an API 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.publisher import DocumentPublisher
from bluesky_stomp.models import Queue, Topic, BasicAuthentication
RE = RunEngine()
username = input("Please enter your username")
password = input("Please enter your password", password=True)
auth = BasicAuthentication(username=username, password=password)
publisher = DocumentPublisher(host="localhost", port=61613, destination=Topic(name="foo"), auth=auth)
RE.subscribe(publisher)
with DeviceCollector():
saxs = saxs()
waxs = waxs()
RE(bp.count([saxs, waxs], num=100))
```
See https://github.com/bluesky/bluesky-kafka for inspiration
## Acceptance Criteria
- There is an importable helper class/method for publishing documents to the message bus
- This can easily be hooked up to a `RunEngine` via `.subsribe()`
- It can authenticate against the broker with a username and password
- Tests
- Example in README
Contributor guide
Assessment
This issue has not been assessed yet.