nsqproducer

package module
v0.0.0-...-da537f9 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2017 License: MIT Imports: 7 Imported by: 1

README

nsqproducer

nsqproducer is a wrap for nsq.Producer but using nsqlookupd to find available endpoint

purpose

nsq.Producer use one nsqd endpoint to publish message.

nsqproducer is a wrap for nsq.Producer, but using nsqlookupd to find all available endpoint.When current using nsqd is unavailable, it will auto search for the next available one.

Once all endpoint is unavailable, it will pull nsqd node list from nsqlookupd again.

usage

nsqlookupdAddrs := []string{"127.0.0.1:4161"}
producer, err := nsqproducer.NewNSQProducer(nsqlookupdAddrs, cfg, &nsqDebugLogger, nsq.LogLevelDebug)
if nil != err {
	return err
}
producer.Publish(topic, body)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoHTTPGet

func DoHTTPGet(reqURL string, args map[string]string) ([]byte, error)

func SetMaxRetryTimes

func SetMaxRetryTimes(tm int)

SetMaxRetryTimes set the retry times if producer connection is break

Types

type INSQProducer

type INSQProducer interface {
	Stop()
	Publish(topic string, body []byte) error
	SetLogger(l logger, lvl nsq.LogLevel)
}

INSQProducer is an interface to export

func NewNSQProducer

func NewNSQProducer(nsqlookupdAddrs []string, config *nsq.Config, l logger, loglvl nsq.LogLevel) (INSQProducer, error)

NewNSQProducer return a NSQProducer instance

@param1 nsqlookupAddr

Jump to

Keyboard shortcuts

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