nsq

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: Apache-2.0 Imports: 7 Imported by: 1

README

NSQ Driver

Implementation of NSQ. Connection will be made via NSQD using NSQ's tcp port (default: 4150). All topics and channels created will have #ephemeral suffix in order to be destroyed once there's no channel subscribed to the topic or no consumer is connected to the channel.

By default, the NSQ log is suppressed. There won't be any log from NSQ telling that the topic is missing or the NSQD cannot be reached. The reason behind this decission is because it's a bit annoying to see the status log of NSQ in regular interval.

Documentation

Index

Constants

View Source
const (
	DefaultWaitDuration = time.Millisecond * 50

	// suffix for nsq topic/channel to make them ephemeral
	Ephemeral = "#ephemeral"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NSQ

type NSQ struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(cfg *config.Resource) (*NSQ, error)

func (*NSQ) Close

func (nm *NSQ) Close() error

to terminate nsq connections

func (*NSQ) Fetch

func (nm *NSQ) Fetch(target string) ([][]byte, error)

to get the message from target that are stored by nsqManager.Listen()

func (*NSQ) Listen

func (nm *NSQ) Listen(target string) error

to listen to target, all messages retrieved should be stored temporarily

func (*NSQ) Open added in v1.4.1

func (nm *NSQ) Open() error

Open satisfies resource interface

func (*NSQ) Publish

func (nm *NSQ) Publish(target string, payload []byte) error

to publish payload to designated target

func (*NSQ) PublishFromFile added in v1.4.1

func (nm *NSQ) PublishFromFile(target string, fileName string) error

PublishFromFile attempts to publish a message read from a file to the passed target

func (*NSQ) Ready

func (nm *NSQ) Ready() error

to check whether nsq is ready to be used, both for publishing or consuming. it is intended not to be cached

func (*NSQ) Reset

func (nm *NSQ) Reset() error

Jump to

Keyboard shortcuts

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