-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for the pub-sub pattern
- Loading branch information
Showing
9 changed files
with
68 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Introduction | ||
|
||
Bonsai.ZeroMQ is a [Bonsai](https://bonsai-rx.org/) interface for [ZeroMQ](https://zeromq.org/) providing a flexible networking and messaging library for coordinating distributed processing. The core patterns discussed in the [ØMQ Guide](https://zguide.zeromq.org/) are exposed via reactive operators and discussed in detail in the [Patterns](patterns.md) chapter. | ||
|
||
You can use Bonsai.ZeroMQ to transmit requests and data across different workflows running in the same computer, or in a different computer. You can also use the package to create endpoints for interfacing Bonsai with other languages supporting ZeroMQ. | ||
|
||
## Installing the package | ||
|
||
To install Bonsai.ZeroMQ use the Bonsai package manager and search for the **Bonsai - ZeroMQ** package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Patterns | ||
|
||
ZeroMQ provides a set of [sockets and patterns](https://zguide.zeromq.org/docs/chapter2/) for building distributed systems. We have adapted these patterns to fit neatly into the Bonsai visual language by defining a set of reactive operators named after each socket type. | ||
|
||
| Pattern | Description | Sockets | | ||
| ------- | ----------- | ------- | | ||
| [Publish-Subscribe](pub-sub.md) | One to many data distribution | <xref href="Bonsai.ZeroMQ.Publisher"/>, <xref href="Bonsai.ZeroMQ.Subscriber"/> | | ||
|
||
Each section in this chapter describes a basic ZeroMQ messaging pattern, usually involving complementary pairs of sockets, and provides examples of use that you can copy and paste directly into the editor. Most examples make use of the [OSC](xref:Bonsai.Osc) package for formatting and parsing binary-coded messages for numeric data, or the <xref href="Bonsai.Vision.EncodeImage"/> and <xref href="Bonsai.Vision.DecodeImage"/> operators for serializing video data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
uid: pub-sub | ||
title: "Publish-Subscribe" | ||
--- | ||
|
||
# Publish-Subscribe | ||
|
||
The publish-subscribe (pub-sub) pattern implements one-way data distribution, in which a <xref href="Bonsai.ZeroMQ.Publisher"/> node pushes a stream of updates to a set of <xref href="Bonsai.ZeroMQ.Subscriber"/> nodes. Messages pushed by the publisher are sent to all subscribers active at the moment of sending the message. | ||
|
||
```mermaid | ||
graph LR | ||
A(Publisher) ---|PUB| B(<p></p>) | ||
B -->|SUB| D(Subscriber) | ||
B -->|SUB| E(Subscriber) | ||
B -->|SUB| F(Subscriber) | ||
``` | ||
|
||
Distribution is fully asynchronous, and publisher and subscriber nodes can be started in any order. Publisher nodes may specify a <xref href="Bonsai.ZeroMQ.Publisher.Topic"/> for each sent message. When connecting to a publisher, subscriber nodes can subscribe to one or more topics. If no topic is specified, subscriber nodes will receive all messages from the publisher. | ||
|
||
> [!Warning] | ||
> Subscriber nodes are not guaranteed to receive the same number of messages sent by the publisher or by other subscribers. Initializing a connection to the publisher can take long enough that messages already being sent are lost, so it is best to assume that pub-sub streams are infinite streams with no beginning or end. | ||
### **Example:** Simple publish-subscribe stream | ||
|
||
In the example below, a periodic timer publishes counter updates with multiple downstream subscribers. The numeric data is packed into an array of bytes for transmission, and parsed back on reception. | ||
|
||
:::workflow | ||
![Pub-Sub workflow](~/workflows/pub-sub.bonsai) | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
- name: Getting Started | ||
href: intro.md | ||
items: | ||
- name: Quickstart | ||
href: intro.md | ||
- name: Patterns | ||
href: patterns.md | ||
items: | ||
- name: Overview | ||
href: patterns.md | ||
- name: Publish-Subscribe | ||
href: pub-sub.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters