nats

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExtRoot = root + ".ext"
)

Variables

This section is empty.

Functions

func NewConn

func NewConn(ctx context.Context, plugins ...Plugin) (*nats.Conn, error)

func NewConnWithOptions

func NewConnWithOptions(ctx context.Context, options *Options, plugins ...Plugin) (*nats.Conn, error)

Types

type Options

type Options struct {
	Url           string
	MaxReconnects int
	ReconnectWait time.Duration
}

func NewOptions

func NewOptions() (*Options, error)

func NewOptionsWithPath

func NewOptionsWithPath(path string) (opts *Options, err error)

type Plugin

type Plugin func(context.Context, *nats.Conn) error

type Publisher

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

func NewPublisher

func NewPublisher(ctx context.Context, middlewares ...PublisherMiddleware) (*Publisher, error)

func NewPublisherWithOptions

func NewPublisherWithOptions(ctx context.Context, options *Options, middlewares ...PublisherMiddleware) (*Publisher, error)

func (*Publisher) Conn

func (p *Publisher) Conn() *nats.Conn

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, msg *nats.Msg) error

type PublisherMiddleware

type PublisherMiddleware interface {
	Before(context.Context, *nats.Conn, *nats.Msg) (context.Context, error)
	After(context.Context) error
}

type Subscriber

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

func NewSubscriber

func NewSubscriber(ctx context.Context, msgHandlers ...msgHandler) (*Subscriber, error)

func NewSubscriberWithOptions

func NewSubscriberWithOptions(ctx context.Context, options *Options, msgHandlers ...msgHandler) (*Subscriber, error)

func (*Subscriber) Conn

func (p *Subscriber) Conn() *nats.Conn

func (*Subscriber) Subscribe

func (p *Subscriber) Subscribe(subj string, queue string, cb nats.MsgHandler) (*nats.Subscription, error)

Directories

Path Synopsis
plugins

Jump to

Keyboard shortcuts

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