Documentation ¶
Overview ¶
package knsq (“knusk”) is a collection of helper and convenience functions for bitly’s nsq library.
See: github.com/bitly/nsq
Index ¶
- Constants
- func AttachEphemeralHandler(topic, channel, lookupd string, handler nsq.Handler) error
- func AttachHandler(topic, channel string, lookupd string, handler nsq.Handler) error
- func MustReader(topic, channel string) *nsq.Reader
- type Client
- type HandlerFunc
- type HttpClient
- type Lookupd
- type Producer
Constants ¶
const (
VERSION = "0.7.2"
)
Variables ¶
This section is empty.
Functions ¶
func AttachEphemeralHandler ¶
AttachEphemeralHandler create a new nsq.Reader for a topic and attaches the given handler to it. The nsq channel to which the handler gets attached will be ephemeral. Ephemeral channels will not be buffered to disk and may drop messages. Ephemeral channels will also not be persisted after its last client disconnects.
func AttachHandler ¶
AttachHandler creates a new nsq.Reader for a topic and attaches the given handler to it.
func MustReader ¶
MustReader calls nsq.NewReader and panics if nsq.NewReader returned an error. nsq.NewReader only fails on invalid topic and channel names.
Types ¶
type Client ¶
type Client interface { // CreateTopic makes sure a topic exists on the given nsqd. CreateTopic(topic string) error // Send sends a message on a topic to the specified nsqd. Send(topic string, body io.Reader) error }
func NewTCPClient ¶
NewTCPClient creates an implementation of the Client interface using the TCP API of NSQd.
type HandlerFunc ¶
HandlerFunc is a type that makes a single function implement to the nsq.Handler interface which consists of only one function (just like http.HandlerFunc and http.Handler).
func (HandlerFunc) HandleMessage ¶
func (f HandlerFunc) HandleMessage(message *nsq.Message) error
type HttpClient ¶
HttpClient implements the Client interface using HTTP requests.
func (HttpClient) CreateTopic ¶
func (h HttpClient) CreateTopic(topic string) error
type Lookupd ¶
type Lookupd string
Lookupd represents a running nsqlookupd instance. The underlying string should be the HTTP address in the form of hostname:port.
func (Lookupd) NSQdInstance ¶
NSQdInstnaces returns a random producer registered with the nsqlookupd.
func (Lookupd) NSQdInstances ¶
NSQdInstnaces returns all producers registered with the nsqlookupd.
type Producer ¶
type Producer struct { Hostname string `json:"hostname"` BroadcastAddress string `json:"broadcast_address"` TcpPort int `json:"tcp_port"` HttpPort int `json:"http_port"` Version string `json:"version"` Topics []string `json:"topics"` }
Producer represents a running NSQd instance registered with a nsqlookupd.