natsio

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginNATSIO = "natsio"
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(ctx context.Context, config cmap.CustomMap) (busPluginTY.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 busPluginTY.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 busPluginTY.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