nats

package
v0.0.0-...-1762b78 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	Host      string        `envconfig:"BROKER_HOST"`
	Port      string        `envconfig:"BROKER_PORT"`
	User      string        `envconfig:"BROKER_USER"`
	Pass      string        `envconfig:"BROKER_PASS"`
	ClusterID string        `envconfig:"BROKER_CLUSTER_ID"`
	Encoder   string        `envconfig:"BROKER_ENCODER" default:"json"`
	Timeout   time.Duration `envconfig:"BROKER_TIMEOUT" default:"10s"`
}

type Nats

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

func New

func New(clientID string, cfg *Broker, logger *log.Logger) (*Nats, error)

func (*Nats) Publish

func (n *Nats) Publish(subject string, payload interface{}) error

Publish publishes the payload argument to the given subject

func (*Nats) Subscribe

func (n *Nats) Subscribe(subject string, handler stan.MsgHandler, subscriberName string) (io.Closer, error)

Subscribe will create a subscription on the given subject and process incoming messages using the specified stan.MsgHandler stan.MsgHandler should explicitly acknowledge the message in case of successful processing -> msg.Ack()

Jump to

Keyboard shortcuts

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