natsio

package module
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

README

nats.io

connectivety to nats.io

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NatsConnection

type NatsConnection interface {
	Close()
	Publish(subj string, msg []byte) error
	Request(subj string, msg []byte, timeout time.Duration) (*nats.Msg, error)
	QueueSubscribe(subj string, queue string, handler nats.MsgHandler) (*nats.Subscription, error)
}

type NatsHandler

type NatsHandler interface {
	Exec() (interface{}, ServiceReply)
}

type NatsHandlerPlainData

type NatsHandlerPlainData interface {
	Exec(data []byte) []byte
}

type NatsService

type NatsService interface {
	PublishExternal(subj string, msg []byte) error
	Publish(subj string, data interface{}) error
	RequestExternal(subj string, msg []byte, timeout time.Duration) ([]byte, error)
	Request(c context.Context, subj string, data interface{}, timeout time.Duration, target interface{}) ServiceReply
	QueueSubscribe(subj, queue string, handler NatsHandler) error
	QueueSubscribeExternal(subj, queue string, handler NatsHandlerPlainData) error
	Subscribe(subj string, handler NatsHandler) error
	SubscribeExternal(subj string, handler NatsHandlerPlainData) error
	Unsubscribe(subj string) error
	QueueUnsubscribe(subj, queue string) error
	SetConnectionFailedHandler(func(err error))
	Connect(natsUrl, serviceName string, authOpt nats.Option,
		connectionAttempts, reconnectionAttempts, reconnectWaitSec, maxPingsOutstanding, pingIntervalSec int) error
	IsNoResponderErr(err error) bool
}

func NewNatsServiceWithBasicAuth

func NewNatsServiceWithBasicAuth(lc fx.Lifecycle, config configuration.Config, logger log.Logger, credentials credentials.CredentialsGetter) NatsService

func NewNatsServiceWithJWTAuth

func NewNatsServiceWithJWTAuth(lc fx.Lifecycle, config configuration.Config, credentials credentials.CredentialsGetter, logger log.Logger) NatsService

func NewNatsServiceWithoutConnection

func NewNatsServiceWithoutConnection(logger log.Logger) NatsService

This allows a 2 phase intialization: Usage: natsSvc := NewNatsServiceWithoutConnection(logger) ... err:=natsSvc.Connect

func NewTraceNatsServiceWithBasicAuth added in v0.5.0

func NewTraceNatsServiceWithBasicAuth(lc fx.Lifecycle, tracer opentracing.Tracer, config configuration.Config, logger log.Logger, credentials credentials.CredentialsGetter) NatsService

func NewTraceNatsServiceWithJWTAuth added in v0.5.0

func NewTraceNatsServiceWithJWTAuth(lc fx.Lifecycle, tracer opentracing.Tracer, config configuration.Config, credentials credentials.CredentialsGetter, logger log.Logger) NatsService

Jump to

Keyboard shortcuts

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