pubsub

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PubSub

type PubSub[T any] struct {
	// contains filtered or unexported fields
}

func NewPubSub

func NewPubSub[T any](params PubSubParams) (*PubSub[T], error)

func (*PubSub[T]) Close

func (p *PubSub[T]) Close(ctx context.Context) (err error)

func (*PubSub[T]) Publish

func (p *PubSub[T]) Publish(ctx context.Context, message T) error

func (*PubSub[T]) Subscribe

func (p *PubSub[T]) Subscribe(ctx context.Context, subscriber pubsub.Subscriber[T]) (err error)

type PubSubParams

type PubSubParams struct {
	// Subject is the NATS subject to publish to. It is also used as the subscription subject if SubscriptionSubject is empty.
	Subject string
	// SubscriptionSubject is the NATS subject to subscribe to. If empty, Subject is used.
	// This is useful when the subscription subject is different from the publishing subject, e.g. when using wildcards.
	SubscriptionSubject string
	// Conn is the NATS connection to use for publishing and subscribing.
	Conn *nats.Conn
}

Jump to

Keyboard shortcuts

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