nats_listener

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNewConnectionToNats

func CreateNewConnectionToNats(preference *NatsConnectionConfiguration) (*nats.Conn, error)

CreateNewConnectionToNats - initialize new connection to nats

Types

type ISubscriber

type ISubscriber interface {
	Subscribe() error
}

type NatsConnectionConfiguration

type NatsConnectionConfiguration struct {
	URL              string       `cf_env:"NATS_URL" cf_default:"nats://localhost:4222"`
	NameClient       string       `cf_env:"NATS_NAME" cf_default:"bomber"`
	MaxWait          int          `cf_env:"NATS_MAX_WAIT" cf_default:"1"`
	ReconnectDelay   int64        `cf_env:"NATS_RECONNECT_DELAY" cf_default:"2"`
	CurrentServiceID string       `cf_env:"BOMBER_ID" cf_default:"15123kjnsjhad"`
	LogLevel         logrus.Level `cf_env:"LOG_LEVEL" cf_default:"error"`
}

func ParseConfiguration

func ParseConfiguration() (*NatsConnectionConfiguration, error)

func (*NatsConnectionConfiguration) CorrectedGeneratingHandlerName

func (config *NatsConnectionConfiguration) CorrectedGeneratingHandlerName()

type Publisher

type Publisher struct {
	Connection *nats.Conn
}

func NewPublisher

func NewPublisher(connection *nats.Conn) *Publisher

func (*Publisher) PublishNewMessage

func (publsh *Publisher) PublishNewMessage(topic string, message []byte) error

type Subscriber

type Subscriber struct {
	Connection *nats.Conn
	// contains filtered or unexported fields
}

func NewSubscriber

func NewSubscriber(connection *nats.Conn, topicName string) *Subscriber

func (*Subscriber) Subscribe

func (subscr *Subscriber) Subscribe(handler nats.MsgHandler) error

Jump to

Keyboard shortcuts

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