messenger

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Messenger

Package for handling messaging between various endpoints.

Each service should be accessible via Websocket for real-time use cases, or view REST API.

websocket

Server package for websocket messaging with frontend.

client

Client Package for connecting to messaging server.

AuthN/AuthZ

  • Organization: ACME
  • Account: FINANCE
  • User: WORKER

server

Server package for messaging - based on NATS.io. For now, we are running this standalone vs. embedded so we can focus. Maybe come back to embedded version in Future.

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func NewClientFromConn(nc *nats.Conn, application, component string) (*Client, error)

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) Close

func (mc *Client) Close()

func (*Client) Connect

func (mc *Client) Connect() error

func (*Client) IsConnected

func (mc *Client) IsConnected() bool

IsConnected returns true if the NATS connection is established and not closed.

func (*Client) NATSCreds

func (mc *Client) NATSCreds() nats.Option

func (*Client) Publish

func (mc *Client) Publish(subject string, msg interface{})

func (*Client) PublishRaw

func (mc *Client) PublishRaw(subject string, data []byte) error

PublishRaw publishes raw bytes to a NATS subject.

func (*Client) RegisterWorker

func (mc *Client) RegisterWorker(subject string, cb func(obj interface{}))

func (*Client) Subscribe

func (mc *Client) Subscribe(subject string, cb func(obj interface{}))

func (*Client) SubscribeRaw

func (mc *Client) SubscribeRaw(subject string, cb func(data []byte))

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)

type Message

type Message struct {
	Method      string            `json:"method"`
	Path        string            `json:"path"`
	QueryParams map[string]string `json:"query_params"`
	Payload     interface{}       `json:"payload"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL