Documentation ¶
Overview ¶
nats_messaging implements convenience routines around the NATS - Go Client (https://github.com/nats-io/nats.go). provides support for OTel trace context propagation via NATs messages using NATS message headers. intended to be used by go apps that want to communicate via NATS pub/sub without having to know much about nats.go
Index ¶
- type Messaging
- func (m *Messaging) Publish(subj string, data []byte) error
- func (m *Messaging) PublishWithTraceContext(ctx context.Context, subj string, data []byte) error
- func (m *Messaging) Shutdown()
- func (m *Messaging) Subscribe(con string, subj string, mh MsgHandler) error
- func (m *Messaging) SubscribeWithTraceContext(con string, subj string, mh MsgHandlerWithTraceContext) error
- type Msg
- type MsgHandler
- type MsgHandlerWithTraceContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Messaging ¶
type Messaging struct { // Js available outside package for stream & consumer management Js nats.JetStreamContext // contains filtered or unexported fields }
this type represents a reference to the nats messaging client. it is obtained via a call to NewMessaging() and is require for all subsequent calls to pub/sub routines: Messaging.Publish(...), Messaging.Subscribe(...), ...
func NewMessaging ¶
initializes a Messaging type. a call to this routine is a prerequisite to pub/sub operations
func NewSecureMessaging ¶
initializes a secure/tls Messaging type. a call to this routine is a prerequisite to pub/sub operations
func (*Messaging) Publish ¶
routine used to Publish a message (represented by []byte) on the given subject
func (*Messaging) PublishWithTraceContext ¶
func (*Messaging) Subscribe ¶
func (m *Messaging) Subscribe(con string, subj string, mh MsgHandler) error
func (*Messaging) SubscribeWithTraceContext ¶
func (m *Messaging) SubscribeWithTraceContext(con string, subj string, mh MsgHandlerWithTraceContext) error
type MsgHandler ¶
type MsgHandler func(msg *Msg)