natstream

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v1.0.0

type Option func(opt *Options)

Option of the NATS subscriber or publisher

func WithClientID added in v1.0.0

func WithClientID(id string) Option

WithClientID puts the client ID value

func WithClusterID added in v1.0.0

func WithClusterID(id string) Option

WithClusterID puts the cluster ID value

func WithContext added in v1.5.0

func WithContext(ctx context.Context) Option

WithContext puts the client context value

func WithEncoder added in v1.0.0

func WithEncoder(encoder encoder.Encoder) Option

WithEncoder set the message encoder

func WithErrorHandler added in v1.0.0

func WithErrorHandler(h nc.ErrorHandler) Option

WithErrorHandler set handler of error processing

func WithGroupName added in v1.0.0

func WithGroupName(name string) Option

WithGroupName puts the name group of the subsciber or publisher

func WithLogger added in v1.0.0

func WithLogger(logger loggerInterface) Option

WithLogger provides logging interface

func WithNatsConn added in v1.0.0

func WithNatsConn(nc *nats.Conn) Option

WithNatsConn is an Option to set the underlying NATS connection to be used by a streaming connection object. When such option is set, closing the streaming connection does not close the provided NATS connection.

func WithNatsOptions added in v1.0.0

func WithNatsOptions(natsOpts ...nstream.Option) Option

WithNatsOptions provides options of the NATS module

func WithNatsURL added in v1.0.0

func WithNatsURL(urlString string) Option

WithNatsURL is an Option to set the URL the client should connect to. The url can contain username/password semantics. e.g. nats://derek:pass@localhost:4222 Comma separated arrays are also supported, e.g. urlA, urlB.

func WithPanicHandler added in v1.0.0

func WithPanicHandler(h nc.PanicHandler) Option

WithPanicHandler set handler of panic processing

func WithTopics added in v1.1.0

func WithTopics(topics ...string) Option

WithTopics will set the list of topics for publishing or subscribing

type Options added in v1.0.0

type Options struct {
	Ctx context.Context

	// Raw options from the "github.com/nats-io/stan.go" module
	NatsOptions []nstream.Option

	// NatsSubscriptions suboptions of subscriptions
	NatsSubscriptions []nstream.Subscription

	// Name of the subscription group
	GroupName string

	// Names of topics for subscribing or publishing
	Topics []string

	// ClusterID common for the group of services
	ClusterID string

	// Client ID unical for the service
	ClientID string

	// ErrorHandler of message processing
	ErrorHandler nc.ErrorHandler

	// PanicHandler process panic
	PanicHandler nc.PanicHandler

	// Message encoder interface
	Encoder encoder.Encoder

	// Logger of subscriber
	Logger loggerInterface
}

Options of the NATS wrapper

type Publisher added in v1.0.0

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

Publisher for NATS queue

func MustNewPublisher added in v1.0.0

func MustNewPublisher(options ...Option) *Publisher

MustNewPublisher of the NATS stream server

func NewPublisher added in v1.0.0

func NewPublisher(options ...Option) (*Publisher, error)

NewPublisher of the NATS stream server

func (*Publisher) Close added in v1.0.0

func (s *Publisher) Close() error

Close nats-stream client

func (*Publisher) Publish added in v1.0.0

func (s *Publisher) Publish(ctx context.Context, messages ...interface{}) (err error)

Publish one or more messages to the pub-service

type Subscriber

type Subscriber struct {
	nc.ModelSubscriber
	// contains filtered or unexported fields
}

Subscriber for NATS queue

func MustNewSubscriber

func MustNewSubscriber(options ...Option) *Subscriber

MustNewSubscriber creates new subscriber object

func NewSubscriber

func NewSubscriber(options ...Option) (*Subscriber, error)

NewSubscriber creates new subscriber object

func (*Subscriber) Close

func (s *Subscriber) Close() error

Close nstream client

func (*Subscriber) Listen

func (s *Subscriber) Listen(ctx context.Context) error

Listen kafka consumer

Jump to

Keyboard shortcuts

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