Documentation ¶
Index ¶
- type Nats
- func (n *Nats) Publish(subject string, data PayloadWithContext) error
- func (n *Nats) PublishRequest(subject string, reply string, data PayloadWithContext) error
- func (n *Nats) QueueSubscribe(route string, group string, handler nats.Handler) error
- func (n *Nats) Request(subject string, data PayloadWithContext, responsePtr interface{}, ...) error
- func (n *Nats) Subscribe(route string, handler nats.Handler) error
- func (n *Nats) UnsubscribeAll()
- type NatsOptions
- type OptionsFunc
- type PayloadWithContext
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Nats ¶
type Nats struct { Opts *NatsOptions EncCon *nats.EncodedConn }
nats.Options wrapper.
func (*Nats) Publish ¶
func (n *Nats) Publish(subject string, data PayloadWithContext) error
Wrapper for nats Publish function. Needs a payload which has a context object (see PayloadWithContext type) Adds a context if it doesn't exist. Otherwise appends which app and time that this message is being sent at. Adds a traceID if not already there
func (*Nats) PublishRequest ¶
func (n *Nats) PublishRequest(subject string, reply string, data PayloadWithContext) error
Wrapper for nats PublishRequest function with context. Adds a context if it doesn't exist. Otherwise appends which app and time that this message is being sent at. Adds a traceID if not already there
func (*Nats) QueueSubscribe ¶
Subscribe to queue group and record subscription to routes
func (*Nats) Request ¶
func (n *Nats) Request(subject string, data PayloadWithContext, responsePtr interface{}, timeout time.Duration) error
Wrapper for nats Request function with context. Adds a context if it doesn't exist. Otherwise appends which app and time that this message is being sent at. Adds a traceID if not already there
type NatsOptions ¶
type NatsOptions struct { nats.Options // contains filtered or unexported fields }
Used to create a nats connection. To be used in conjunction with a Nats controller to subscribe routes.
func NewNatsOptions ¶
func NewNatsOptions(optionFuncs ...OptionsFunc) (options *NatsOptions)
Initiating nats with default options and then applies each option func in order on top of that.
func (*NatsOptions) Connect ¶
func (natsOpts *NatsOptions) Connect() (natsObj *Nats, err error)
Start subscribing to subjects/routes.
func (*NatsOptions) GetEncoding ¶
func (n *NatsOptions) GetEncoding() string
func (*NatsOptions) SetEncoding ¶
func (n *NatsOptions) SetEncoding(enc string)
Set the encoding (json/gob)
type OptionsFunc ¶
type OptionsFunc func(*NatsOptions) error
Function for applying options to NatsOptions in NewNatsOptions Using a function allows for a chain or heirarchy when applying them eg func1 then func2 then func3 Internally allows for default options to be applied first.
type PayloadWithContext ¶
type PayloadWithContext interface { proto.Message GetContext() *NatsContext SetContext(*NatsContext) }
For use when using nats request/publish/publishrequest wrapper functions
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Holds route info including subscription holds route,handler,nats subscripiton and queue group.
func (*Route) GetHandler ¶
func (r *Route) GetHandler() nats.Handler
func (*Route) GetQueueGroup ¶
func (*Route) GetSubscription ¶
func (r *Route) GetSubscription() nats.Handler
Directories ¶
Path | Synopsis |
---|---|
A default nats initialization.
|
A default nats initialization. |
Package protobuf is a generated protocol buffer package.
|
Package protobuf is a generated protocol buffer package. |