subscription

package
v0.15.17-rc.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithNats added in v0.15.4

func WithNats(conn *nats.Conn) optFn

Types

type Manager

type Manager interface {
	Subscribe(resourceID string, subscriber Subscriber) Subscription
	GetSubscription(resourceID string, subscriptionID string) Subscription

	PublishUpdate(message Message)
	Publish(resourceID string, message any)
}

func NewManager

func NewManager(opts ...optFn) Manager

type Message

type Message struct {
	ResourceID string
	Type       string
	Content    interface{}
}

func DecodeMessage added in v0.15.4

func DecodeMessage(data []byte) (Message, error)

func (Message) DecodeContent added in v0.15.4

func (m Message) DecodeContent(output interface{}) error

func (Message) Encode added in v0.15.4

func (m Message) Encode() ([]byte, error)

func (Message) EncodeContent added in v0.15.4

func (m Message) EncodeContent() (Message, error)

type Subscriber

type Subscriber interface {
	ID() string
	Notify(message Message) error
}

func NewSubscriberFunction

func NewSubscriberFunction(function func(Message) error) Subscriber

type SubscriberFunction

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

func (*SubscriberFunction) ID

func (sf *SubscriberFunction) ID() string

func (*SubscriberFunction) Notify

func (sf *SubscriberFunction) Notify(message Message) error

type Subscription

type Subscription interface {
	Unsubscribe() error
}

Jump to

Keyboard shortcuts

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