natsio

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 19 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.

Documentation

Index

Constants

View Source
const (
	PluginNATSIO = "natsio"
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(ctx context.Context, config cmap.CustomMap) (busTY.Plugin, error)

NewClient nats.io client

func NewWebsocket

func NewWebsocket(serverURL string, tlsConfig *tls.Config, timeout time.Duration, wsOptions *WebsocketOptions) (net.Conn, error)

NewWebsocket returns a net.Conn compatible interface using the gorilla/websocket package

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client struct

func (*Client) Close

func (c *Client) Close() error

Close implementation

func (*Client) Name

func (c *Client) Name() string

func (*Client) PausePublish

func (c *Client) PausePublish()

func (*Client) Publish

func (c *Client) Publish(topic string, data interface{}) error

Publish a data to a topic

func (*Client) QueueSubscribe

func (c *Client) QueueSubscribe(topic, queueName string, handler busTY.CallBackFunc) (int64, error)

QueueSubscribe a topic with queue name

func (*Client) QueueUnsubscribe

func (c *Client) QueueUnsubscribe(topic, queueName string, subscriptionID int64) error

QueueUnsubscribe a topic

func (*Client) ResumePublish

func (c *Client) ResumePublish()

func (*Client) Subscribe

func (c *Client) Subscribe(topic string, handler busTY.CallBackFunc) (int64, error)

Subscribe a topic

func (*Client) TopicPrefix

func (c *Client) TopicPrefix() string

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(topic string, subscriptionID int64) error

QueueUnsubscribe a topic

func (*Client) UnsubscribeAll

func (c *Client) UnsubscribeAll(topic string) error

UnsubscribeAll topics

type Config

type Config struct {
	Type                 string            `yaml:"type"`
	ServerURL            string            `yaml:"server_url"`
	Token                string            `yaml:"token"`
	Username             string            `yaml:"username"`
	Password             string            `yaml:"password"`
	Insecure             bool              `yaml:"insecure"`
	BufferSize           int               `yaml:"buffer_size"`
	RetryOnFailedConnect bool              `yaml:"retry_on_failed_connect"`
	ConnectionTimeout    string            `yaml:"connection_timeout"`
	MaximumReconnect     int               `yaml:"maximum_reconnect"`
	ReconnectWait        string            `yaml:"reconnect_wait"`
	WebsocketOptions     *WebsocketOptions `yaml:"websocket_options"`
	TopicPrefix          string            `yaml:"topic_prefix"`
}

Config details of the client

type CustomDialer

type CustomDialer struct {
	// contains filtered or unexported fields
}

CustomDialer struct

func NewCustomDialer

func NewCustomDialer(cfg *Config, logger *zap.Logger) (*CustomDialer, error)

NewCustomDialer returns a custom dialer

func (*CustomDialer) Dial

func (cd *CustomDialer) Dial(network, address string) (net.Conn, error)

Dial implementation

type WebsocketOptions

type WebsocketOptions struct {
	RequestHeader   http.Header `yaml:"request_header"`
	ReadBufferSize  int         `yaml:"read_buffer_size"`
	WriteBufferSize int         `yaml:"write_buffer_size"`
}

WebsocketOptions are config options for a websocket dialer

Jump to

Keyboard shortcuts

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