repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

pico / pkg / pubsub
Eric Bower  ·  2026-01-25

pubsub.go

 1package pubsub
 2
 3import (
 4	"context"
 5	"io"
 6	"iter"
 7)
 8
 9/*
10PubSub is our take on a basic publisher and subscriber interface.
11
12It has a few notable requirements:
13- Each operation must accept an array of channels
14- A way to send, receive, and stream data between clients
15
16PubSub also inherits the properties of a Broker.
17*/
18type PubSub interface {
19	Broker
20	GetPubs() iter.Seq2[string, *Client]
21	GetSubs() iter.Seq2[string, *Client]
22	GetPipes() iter.Seq2[string, *Client]
23	Pipe(ctx context.Context, ID string, rw io.ReadWriter, channels []*Channel, replay bool) (error, error)
24	Sub(ctx context.Context, ID string, rw io.ReadWriter, channels []*Channel, keepAlive bool) error
25	Pub(ctx context.Context, ID string, rw io.ReadWriter, channels []*Channel, blockWrite bool) error
26}