Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WaitTermSig ¶ added in v1.4.1
WaitTermSig wait for termination signal
Types ¶
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer instance
func NewConsumer ¶
func NewConsumer(cfg ConsumerConfig) *Consumer
NewConsumer will instantiate the nsq consumer
func (*Consumer) RegisterHandler ¶
func (c *Consumer) RegisterHandler(handler ConsumerHandler)
RegisterHandler will register the consumer handlers
func (*Consumer) Run ¶
Run will connecting all registered consumer handlers to the nsqlookupd address
type ConsumerConfig ¶
ConsumerConfig config for the consumer instance
type ConsumerHandler ¶
type ConsumerHandler struct { Topic string Channel string Concurrent int MaxAttempts uint16 MaxInFlight int Enable bool Handler func(message IMessage) error }
ConsumerHandler handler for consumer
type IMessage ¶
type IMessage interface { // Finish sends a FIN command to the nsqd which // sent this message Finish() // RequeueWithoutBackoff sends a REQ command to the nsqd which // sent this message, using the supplied delay. // // Notably, using this method to respond does not trigger a backoff // event on the configured Delegate. RequeueWithoutBackoff(delay time.Duration) // Requeue sends a REQ command to the nsqd which // sent this message, using the supplied delay. Requeue(delay time.Duration) // GetAttempts will get the current attempts GetAttempts() uint16 // GetBody will get the body value GetBody() []byte }
IMessage interface define contract for nsq message in handler
type Message ¶
type Message struct {
*nsq.Message
}
Message alias for built in nsq message
func (*Message) GetAttempts ¶
GetAttempts return number of how many this message enter the consumer
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher is struct for publisher
func NewPublisher ¶
NewPublisher will create new publisher instance leaf the prefix empty
func (*Publisher) Publish ¶
Publish will publish the data using json format, by default will always use the prefix in the topic
func (*Publisher) PublishWithoutPrefix ¶
PublishWithoutPrefix will publish the data using json format without prefix in the topic