nsq

package
v0.0.0-...-75a017b Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

示例 https://github.com/nsqio/nsq/tree/master/apps

必须先调用InitProducer初始化生产者

Index

Constants

This section is empty.

Variables

View Source
var Producer *nsq.Producer

Producer will lazily connect to that instance (and re-connect) when Publish commands are executed.

Functions

func Consume

func Consume(addr, topic, channel string, hs ...Handler) error

Consume 消费消息,addr是nsqlookupd地址

func InitProducer

func InitProducer(addr string) error

InitProducer 初始化生产者

func Publish

func Publish(topic string, body []byte) error

Publish 同步发送单个消息

func PublishStr

func PublishStr(topic, body string) error

PublishStr 同步发送单个消息字符串

func StopProducer

func StopProducer()

StopProducer 停止生产者

Types

type Handler

type Handler func(*nsq.Message) error

Handler 实现 nsq.Handler 接口

func (Handler) HandleMessage

func (h Handler) HandleMessage(m *nsq.Message) error

HandleMessage 处理消息 Returning nil will automatically send a FIN command to NSQ to mark the message as processed. Returning a non-nil error will automatically send a REQ command to NSQ to re-queue the message.

Jump to

Keyboard shortcuts

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