Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 1.53 KB

README.md

File metadata and controls

50 lines (35 loc) · 1.53 KB

bluesky-nats

This module allows to:

  • publish Bluesky documents to a NATS JetStream
  • consume a NATS JetStream

Installation

Install from pypi

uv add bluesky-nats

Install with dependecies to run the examples

uv add bluesky-nats --extra examples

Prerequisites

The module requires a NATS JetStream-enabled server. If not explicitly specified, the Publisher will automatically publish to the NATS JetStream "bluesky". Make sure that the respective JetStream is available on the server and that your "subject" pattern matches the configuration.

A simple Docker setup for local development and testing is provided in the docker directory, with a Readme for guidance.

Examples

This is the most basic example to create a NATS publisher subscribed to RE documents.

from bluesky.run_engine import RunEngine

from bluesky_nats.nats_client import NATSClientConfig
from bluesky_nats.nats_publisher import CoroutineExecutor, NATSPublisher

if __name__ == "__main__":
    RE = RunEngine({})
    config = NATSClientConfig()

    nats_publisher = NATSPublisher(
        client_config=config,
        executor=CoroutineExecutor(RE.loop),
        subject_factory="events.nats-bluesky",
    )

    RE.subscribe(nats_publisher)

Follow the instructions for more information about the examples.