DiamondLightSource / DiamondLightSource/bluesky-stomp

Easy publishing mechanism from `RunEngine`

Open
#20 0 comments 0 reactions 0 assignees View on GitHub
enhancement
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

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.