Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus combines a consumer and producer into a single struct and implements both the Consumer and Producer interfaces.
Bus is the same as getting a Consumer and Producer separately but having them available in a single object.
Calling Stop() will stop the producer first then the consumer.
type Consumer ¶
type Consumer interface { // Msg returns the bus msg bytes. If msg is // known to be the last then done should be true. msg may be // nil and done can be true. err should never be // io.EOF. // // Once the last message has been received, subsequent // calls to Msg should not block and always return // msg == nil (or len == 0), done == true and err == nil. // // A call to Msg should block until either a msg // is received or Stop has been called. // // Once Stop has been called subsequent calls to Msg // should not block and immediately return with // msg == nil (or len == 0), done == true and err == nil. Msg() (msg []byte, done bool, err error) Stop() error Info() info.Consumer }
func NewConsumer ¶
NewConsumer creates a bus consumer from BusConfig.
type Options ¶
type Options struct { // Possible Values: // - "stdio" (generic stdin, stdout) // - "stdin" (for consumer) // - "stdout" (for producer) // - "stderr" (for producer) // - "null" (for producer) // - "file" // - "nsq" // = "pubsub" // - "nop" - no-operation bus for testing Bus string `toml:"bus" comment:"task message bus (nsq, pubsub, file, stdio)"` InBus string `toml:"in_bus" commented:"true" comment:"set a different consumer bus type than producer (nsq, pubsub, file, stdin)"` OutBus string `` /* 131-byte string literal not displayed */ // consumer topic and channel InTopic string `toml:"in_topic" commented:"true" comment:"for file bus in_topic is a file name"` InChannel string `toml:"in_channel" commented:"true" comment:"for pubsub this is the subscription name"` // for "nsq" bus type NSQdHosts []string `toml:"nsqd_hosts" commented:"true" comment:"ndqd host names for producer or consumer"` LookupdHosts []string `toml:"lookupd_hosts" commented:"true" comment:"nsq lookupd host names consumer only"` // for "pubsub" bus type PubsubHost string `toml:"pubsub_host" commented:"true" comment:"pubsub host only for emulator"` ProjectID string `toml:"project_id" commented:"true" comment:"pubsub goolge project name"` JSONAuth string `toml:"json_auth" commented:"true" comment:"pubsub json data for authentication"` // NopMock for "nop" bus type, // Can be set in order to // mock various return scenarios. // // Supported Values: // - "init_err" - returns err on initialization: either NewProducer or NewConsumer // - "err" - every method returns an error // - "send_err" - returns err when Producer.Send() is called. // - "msg_err" - returns err on Consumer.Msg() call. // - "msg_done" - returns a nil task message done=true on Consumer.Msg() call. // - "msg_msg_done" - returns a non-nil task message and done=true Consumer.Msg() call. // - "stop_err" - returns err on Stop() method call NopMock string `toml:"-"` }
Options is a general config struct that provides all potential config values for all bus types.
func NewOptions ¶
Click to show internal directories.
Click to hide internal directories.