nats

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 8 Imported by: 0

README

nats

nats

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDrainFailed       = errors.New("drain failed")
	ErrUnsubscribeFailed = errors.New("unsubscribe failed")
	ErrInvalidConfig     = errors.New("invalid config value")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr       string // "nats://localhost:4222, nats://localhost:4223, nats://localhost:4224"
	StreamName string
	Subjects   []string
}

type Handler added in v0.3.0

type Handler func(ctx context.Context, msg *Message) error

Handler to handle sub message.

type JetstreamClient added in v0.6.1

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

func NewJetstream added in v0.6.1

func NewJetstream(config *Config, opts ...Option) (*JetstreamClient, error)

func (*JetstreamClient) Close added in v0.6.1

func (c *JetstreamClient) Close()

func (*JetstreamClient) Connect added in v0.6.1

func (c *JetstreamClient) Connect() (err error)

func (*JetstreamClient) Drain added in v0.6.1

func (c *JetstreamClient) Drain() error

func (*JetstreamClient) Publish added in v0.6.1

func (c *JetstreamClient) Publish(ctx context.Context, subject string, data []byte) (*PubAck, error)

func (*JetstreamClient) Subscribe added in v0.6.1

func (c *JetstreamClient) Subscribe(subject string, handler Handler, opts ...nats.SubOpt) (*nats.Subscription, error)

func (*JetstreamClient) Unsubscribe added in v0.6.1

func (c *JetstreamClient) Unsubscribe() error

type Logger added in v0.6.1

type Logger interface {
	Warn(ctx context.Context, args ...interface{})
	Warnf(ctx context.Context, template string, args ...interface{})
	Error(ctx context.Context, args ...interface{})
	Errorf(ctx context.Context, template string, args ...interface{})
}

type Message added in v0.3.0

type Message = nats.Msg

Message is nats.Msg.

type NatsClient added in v0.6.1

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

func New added in v0.3.0

func New(config *Config, opts ...Option) (*NatsClient, error)

func (*NatsClient) Close added in v0.6.1

func (c *NatsClient) Close()

func (*NatsClient) Connect added in v0.6.1

func (c *NatsClient) Connect() (err error)

func (*NatsClient) Drain added in v0.6.1

func (c *NatsClient) Drain() error

func (*NatsClient) Publish added in v0.6.1

func (c *NatsClient) Publish(ctx context.Context, subject string, data []byte) error

func (*NatsClient) Subscribe added in v0.6.1

func (c *NatsClient) Subscribe(subject string, handler Handler) (*nats.Subscription, error)

func (*NatsClient) Unsubscribe added in v0.6.1

func (c *NatsClient) Unsubscribe() error

type NatsOption added in v0.3.1

type NatsOption = nats.Option // nolint:golint,revive // need nats option.

type Option added in v0.3.0

type Option func(*options)

func WithNatsOptions added in v0.3.0

func WithNatsOptions(opts ...NatsOption) Option

func WithStreamConfig added in v0.3.0

func WithStreamConfig(cfg *StreamConfig) Option

func WithTracer added in v0.3.0

func WithTracer(tracer trace.Tracer) Option

func WithWarnHandler added in v0.6.1

func WithWarnHandler(logger Logger) Option

type PubAck added in v0.3.0

type PubAck = nats.PubAck

type StreamConfig added in v0.3.1

type StreamConfig = nats.StreamConfig

Jump to

Keyboard shortcuts

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