Documentation ¶
Index ¶
- Variables
- func NewNsqHandler(ctx context.Context, n *Nsq, topic string, handler broker.Handler) *nsqHandler
- func NewNsqSubscriber(n *Nsq, topic string, opts ...broker.SubscribeOption) *subscriber
- func WithChannelName(name string) broker.SubscribeOption
- type Config
- type Initializer
- type Lookupd
- type Nsq
- func (n *Nsq) HasInitializer() bool
- func (n *Nsq) Initializer() component.Initializer
- func (n *Nsq) Logger() logger.Logger
- func (n *Nsq) Publish(ctx context.Context, topic string, message interface{}, ...) error
- func (n *Nsq) String() string
- func (n *Nsq) Subscribe(ctx context.Context, topic string, handler broker.Handler, ...) error
- func (n *Nsq) Unsubscribe(topic string) error
- type Producer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidMessageHandler returned when the message handler doesn't implement the underlying interface ErrInvalidMessageHandler = errors.New("invalid message handler provided") )
Functions ¶
func NewNsqHandler ¶
NewNsqHandler creates a new nsq message Handler
func NewNsqSubscriber ¶
func NewNsqSubscriber(n *Nsq, topic string, opts ...broker.SubscribeOption) *subscriber
NewNsqSubscriber returns a new subscriber instance for NSQ subscription
func WithChannelName ¶
func WithChannelName(name string) broker.SubscribeOption
WithChannelName defines a channel name for the subscriber
Types ¶
type Config ¶
Config holds database configuration
func (*Config) NSQConfig ¶
func (c *Config) NSQConfig() *nsq.Config
NSQConfig returns the new config
func (*Config) UnmarshalEnv ¶
UnmarshalEnv env.EnvSet to Config
type Initializer ¶
type Initializer struct {
// contains filtered or unexported fields
}
func NewInitializer ¶
func NewInitializer(n *Nsq) *Initializer
NewInitializer returns a new JetStream Initialiazer
func (*Initializer) AddDependency ¶
func (i *Initializer) AddDependency(dep interface{}) error
AddDependency adds necessary service components as dependencies
func (*Initializer) CanRun ¶
func (i *Initializer) CanRun() bool
CanRun returns true if the component has anything to Run
func (*Initializer) CanStop ¶
func (i *Initializer) CanStop() bool
CanRun returns true if the component has anything to Run
func (*Initializer) Dependencies ¶
func (i *Initializer) Dependencies() []string
Dependencies returns the string names of service components that are required as dependencies for this component
type Lookupd ¶
type Lookupd struct { Host string `env:"BROKER_NSQ_LOOKUPD_HOST,default=127.0.0.1"` Port string `env:"BROKER_NSQ_LOOKUPD_PORT,default=4161"` }
Lookup holds config for NSQLookupd
type Nsq ¶
type Nsq struct { Producer *nsq.Producer Consumers map[string]*nsq.Consumer *Config // contains filtered or unexported fields }
Nsq holds our broker instance
func (*Nsq) HasInitializer ¶
func (*Nsq) Initializer ¶
func (n *Nsq) Initializer() component.Initializer
func (*Nsq) Publish ¶
func (n *Nsq) Publish(ctx context.Context, topic string, message interface{}, opts ...broker.PublishOption) error
Publish publishes the topic message
func (*Nsq) Subscribe ¶
func (n *Nsq) Subscribe(ctx context.Context, topic string, handler broker.Handler, opts ...broker.SubscribeOption) error
Subscribe subcribes for the given topic
func (*Nsq) Unsubscribe ¶
Ubsubscribe method is not applicable