pubsub

package
v0.2.18 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 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"`
	State       eventstate.Type `json:"state"`
	Target      *string         `json:"target"`
	Detail      any             `json:"detail"`
	StateDetail any             `json:"state_detail"`
	SessionID   *string         `json:"session_id"`
	ElementKey  *string         `json:"element_key"`
}

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