pubsub

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: MIT Imports: 8 Imported by: 1

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, events ...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 {
	Type         *string `json:"type"`
	Target       *string `json:"target"`
	TemplateName *string `json:"template_name"`
	Data         any     `json:"data"`
}

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