nsqlbproducer

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 11 Imported by: 0

README

Package nsqlbproducer v1.1.2

nsqlbproducer is used to publish a nsq message with support for multiple nsqd instances. This is the library of choice when writing a project which requires to send a nsq message.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StrategiesFromName = map[string]LBStrategy{
		"":         FallbackStrategy,
		"fallback": FallbackStrategy,
		"random":   RandomStrategy,
	}
)

Functions

This section is empty.

Types

type FromEnvOpts

type FromEnvOpts struct {
	Logger     logrus.FieldLogger
	SkipLogSet map[string]bool
}

type Host

type Host struct {
	Host string
	Port string
}

func (Host) String

func (h Host) String() string

type LBProducerOpts

type LBProducerOpts struct {
	Hosts          []Host
	NsqConfig      *nsq.Config
	Logger         logrus.FieldLogger
	SkipLogSet     map[string]bool
	Strategy       LBStrategy
	PublishTimeout time.Duration
}

type LBStrategy

type LBStrategy int
const (
	FallbackStrategy LBStrategy = iota
	RandomStrategy
)

type NsqLBProducer

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

NsqLBProducer a producer that distribute nsq messages across a set of node if a node send an error when receiving the message it will try with another node of the set

func FromEnv

func FromEnv(opts FromEnvOpts) (*NsqLBProducer, error)

func New

func New(opts LBProducerOpts) (*NsqLBProducer, error)

func (*NsqLBProducer) DeferredPublish

func (p *NsqLBProducer) DeferredPublish(ctx context.Context, topic string, delay int64, message nsqproducer.NsqMessageSerialize) error

func (*NsqLBProducer) Ping

func (p *NsqLBProducer) Ping() error

Ping return an error if all the nodes are unreachable

func (*NsqLBProducer) Publish

func (p *NsqLBProducer) Publish(ctx context.Context, topic string, message nsqproducer.NsqMessageSerialize) error

func (*NsqLBProducer) Stop

func (p *NsqLBProducer) Stop()

type PublishPinger

type PublishPinger interface {
	Publish(context.Context, string, nsqproducer.NsqMessageSerialize) error
	DeferredPublish(context.Context, string, int64, nsqproducer.NsqMessageSerialize) error
	Ping() error
	Stop()
}

Directories

Path Synopsis
Package nsqlbproducermock is a generated GoMock package.
Package nsqlbproducermock is a generated GoMock package.

Jump to

Keyboard shortcuts

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