pubsub

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	// Publish publishes a events to a channel.
	Publish(ctx context.Context, channel string, event Event) error
	// Subscribe subscribes to a channel.
	Subscribe(ctx context.Context, channel string) (Subscription, error)
	// HasSubscribers returns true if there are subscribers to the given pattern.
	HasSubscribers(ctx context.Context, pattern string) bool
}

Adapter is an interface for a pubsub adapter. It allows to publish and subscribe []PubsubEvent to views.

func NewInmem

func NewInmem() Adapter

NewInmem creates a new in-memory pubsub adapter.s

func NewRedis

func NewRedis(client *redis.Client) Adapter

NewRedis creates a new redis pubsub adapter.

type Event added in v0.1.3

type Event struct {
	ID         *string         `json:"id,omitempty"`
	State      eventstate.Type `json:"state,omitempty"`
	Target     *string         `json:"target,omitempty"`
	Detail     *dom.Detail     `json:"detail,omitempty"`
	SessionID  *string         `json:"session_id,omitempty"`
	ElementKey *string         `json:"element_key,omitempty"`
}

type Subscription

type Subscription interface {
	// C returns a receive-only go channel of events published
	C() <-chan Event
	// Close closes the subscription.
	Close()
}

Subscription is a subscription to a channel.

Jump to

Keyboard shortcuts

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