Documentation
¶
Index ¶
- Variables
- type Client
- func (mc *Client) Close()
- func (mc *Client) Connect() error
- func (mc *Client) IsConnected() bool
- func (mc *Client) NATSCreds() nats.Option
- func (mc *Client) Publish(subject string, msg interface{})
- func (mc *Client) PublishRaw(subject string, data []byte) error
- func (mc *Client) RegisterWorker(subject string, cb func(obj interface{}))
- func (mc *Client) Subscribe(subject string, cb func(obj interface{}))
- func (mc *Client) SubscribeRaw(subject string, cb func(data []byte))
- func (mc *Client) UnSubscribe()
- type ClientOptions
- type Message
Constants ¶
This section is empty.
Variables ¶
var (
QUEUE_GROUP = "workers"
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
AccountID string
Client *nats.EncodedConn
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(options *ClientOptions) (*Client, error)
func NewClientFromConn ¶
NewClientFromConn wraps an already established NATS connection, for a process that runs its own embedded server or a test that does not need the mTLS and JWT handshake of NewClient. Closing the client closes nc.
func (*Client) IsConnected ¶
IsConnected returns true if the NATS connection is established and not closed.
func (*Client) PublishRaw ¶
PublishRaw publishes raw bytes to a NATS subject.
func (*Client) RegisterWorker ¶
func (*Client) SubscribeRaw ¶
SubscribeRaw subscribes to a NATS subject and receives raw byte messages.
func (*Client) UnSubscribe ¶
func (mc *Client) UnSubscribe()
type ClientOptions ¶
type ClientOptions struct {
Application string `json:"application"`
Component string `json:"component"`
// can get the account id from the JWT, but adding
// here for convenience
AccountID string `json:"account_id"`
PrivateKey []byte `json:"private_key"`
Certificate []byte `json:"certificate"`
CA []byte `json:"ca"`
JWT string `json:"jwt"`
Seed string `json:"seed"`
ControllerURL string `json:"controller_url"`
}
func (*ClientOptions) GetCertificate ¶
func (options *ClientOptions) GetCertificate() (tls.Certificate, error)
func (*ClientOptions) GetTLSConfig ¶
func (options *ClientOptions) GetTLSConfig() (*tls.Config, error)