nats

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClientDisconnected = errors.New("could not reach nats: connection closed")
)

Functions

This section is empty.

Types

type AddStreamOptions

type AddStreamOptions struct {
	StreamName string
}

type Client

type Client interface {
	server.NamedMonitor
	io.Closer

	AddStream(ctx context.Context, opts *AddStreamOptions) error
	Publish(ctx context.Context, opts *PublishOptions) error
}

type ClientOption

type ClientOption func(*DefaultClient)

func WithEventListeners added in v0.2.1

func WithEventListeners(listeners ...EventListener) ClientOption

func WithLogger

func WithLogger(logger *slog.Logger) ClientOption

func WithNatsUrl

func WithNatsUrl(url string) ClientOption

type DefaultClient

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

func NewDefaultClient

func NewDefaultClient(opts ...ClientOption) (*DefaultClient, error)

func (*DefaultClient) AddStream

func (c *DefaultClient) AddStream(ctx context.Context, opts *AddStreamOptions) error

func (*DefaultClient) Close

func (c *DefaultClient) Close() error

func (*DefaultClient) Monitor

func (c *DefaultClient) Monitor(_ context.Context) error

func (*DefaultClient) Name

func (c *DefaultClient) Name() string

func (*DefaultClient) Publish

func (c *DefaultClient) Publish(ctx context.Context, opts *PublishOptions) error

type EventListener added in v0.2.1

type EventListener func(*DefaultClient)

func OnMsgFailedEvent added in v0.2.1

func OnMsgFailedEvent(onMsgFailedEvent func(subj string, duration time.Duration)) EventListener

func OnMsgPublishedEvent added in v0.2.1

func OnMsgPublishedEvent(onMsgPublishedEvent func(subj string, duration time.Duration)) EventListener

type PublishOptions

type PublishOptions struct {
	Subj  string
	MsgId string
	Data  []byte
}

Jump to

Keyboard shortcuts

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