consumer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2015 License: MIT Imports: 5 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(addrs ...string) error

Connect - Look for Consumer.Connect() (on default consumer)

func ConnectLookupd

func ConnectLookupd(addrs ...string) error

ConnectLookupd - Look for Consumer.ConnectLookupd() (on default consumer)

func Register

func Register(topic, channel string, maxInFlight int, fnc Handler) error

Register - Look for Consumer.Register() (on default consumer)

func Start

func Start(debug bool)

Start - Look for Consumer.Start() (on default consumer)

func WithMessage

func WithMessage(ctx context.Context, msg *Message) context.Context

WithMessage - Returns nsq message from context.

Types

type Consumer

type Consumer struct {
	Logger   *log.Logger
	LogLevel nsq.LogLevel
	Config   *nsq.Config
	// contains filtered or unexported fields
}

Consumer - NSQ messages consumer.

var DefaultConsumer *Consumer

DefaultConsumer - Shortcuts for apps using only one consumer.

func New

func New() *Consumer

New - Creates a new consumer structure

func (*Consumer) Connect

func (c *Consumer) Connect(addrs ...string) error

Connect - Connects all readers to NSQ

func (*Consumer) ConnectLookupd

func (c *Consumer) ConnectLookupd(addrs ...string) error

ConnectLookupd - Connects all readers to NSQ lookupd

func (*Consumer) Register

func (c *Consumer) Register(topic, channel string, maxInFlight int, handler Handler) error

Register - Registers topic/channel handler for messages This function creates a new nsq.Reader

func (*Consumer) Start

func (c *Consumer) Start(debug bool) error

Start - Just waits

func (*Consumer) Stop

func (c *Consumer) Stop()

Stop - Gracefully closes all consumers.

type Handler

type Handler func(*Message)

Handler - Function that handles incoming message.

type Message

type Message struct {
	*nsq.Message
}

Message - Inherent nsq

func MessageFromContext

func MessageFromContext(ctx context.Context) (*Message, bool)

MessageFromContext - Returns nsq message from context.

func (*Message) Fail

func (m *Message) Fail()

Fail - Mark message as failed to process

func (*Message) Finish

func (m *Message) Finish(success bool)

Finish - Finish processing message

func (*Message) GiveUp

func (m *Message) GiveUp()

GiveUp - Finish message with success state because message never will be possible to process

func (*Message) ReadJSON

func (m *Message) ReadJSON(v interface{}) error

ReadJSON - Unmarshals JSON message body to interface.

func (*Message) Success

func (m *Message) Success()

Success - Finish message as successfully proccessed

Jump to

Keyboard shortcuts

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