pubsub

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package pubsub provides a simple publish-subscribe mechanism for GraphQL subscriptions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSub

type PubSub struct {
	// contains filtered or unexported fields
}

PubSub manages subscriptions and message distribution.

func New

func New() *PubSub

New creates a new PubSub instance.

func (*PubSub) Publish

func (ps *PubSub) Publish(topic Topic, filter string, message interface{})

Publish sends a message to all subscribers of a topic. If filter is non-empty, only sends to subscribers with matching filter or empty filter.

func (*PubSub) PublishAll

func (ps *PubSub) PublishAll(topic Topic, message interface{})

PublishAll sends a message to all subscribers of a topic regardless of filter.

func (*PubSub) Subscribe

func (ps *PubSub) Subscribe(topic Topic, filter string, bufferSize int) *Subscriber

Subscribe creates a new subscription for a topic.

func (*PubSub) SubscriberCount

func (ps *PubSub) SubscriberCount(topic Topic) int

SubscriberCount returns the number of subscribers for a topic.

func (*PubSub) Unsubscribe

func (ps *PubSub) Unsubscribe(sub *Subscriber)

Unsubscribe removes a subscription.

type Subscriber

type Subscriber struct {
	ID      string
	Topic   Topic
	Filter  string // Optional filter value (e.g., projectId, universe)
	Channel chan interface{}
}

Subscriber represents a subscription channel.

type Topic

type Topic string

Topic represents a subscription topic.

const (
	TopicDMXOutput       Topic = "DMX_OUTPUT_CHANGED"
	TopicProjectUpdated  Topic = "PROJECT_UPDATED"
	TopicPreviewSession  Topic = "PREVIEW_SESSION_UPDATED"
	TopicCueListPlayback Topic = "CUE_LIST_PLAYBACK_UPDATED"
	TopicSystemInfo      Topic = "SYSTEM_INFO_UPDATED"
	TopicWiFiStatus      Topic = "WIFI_STATUS_UPDATED"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL