client

package
v1.2.9-0...-216e217 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	JS nats.JetStreamContext
	// contains filtered or unexported fields
}

WebSocketClient return websocket client connection

func NewClient

func NewClient(host string, opts ...Option) *Client

NewClient create new connection

func (*Client) Connect

func (c *Client) Connect() (err error)

func (*Client) Disconnect

func (c *Client) Disconnect() error

Close will unsubscribe all subjects and shutdown connection

func (*Client) IsConnected

func (c *Client) IsConnected() bool

func (*Client) Publish

func (c *Client) Publish(subject string, data string) error

func (*Client) PublishRaw

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

func (*Client) Subscribe

func (c *Client) Subscribe(subject string, cb SubscribeCallback, opts ...SubscribeOption) error

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(subject string) error

func (*Client) WithAck

func (c *Client) WithAck() SubscribeOption

func (*Client) WithCache

func (c *Client) WithCache() SubscribeOption

type Option

type Option func(c *Client)

func WithAuth

func WithAuth(username string, password string) Option

type SubjectMessage

type SubjectMessage struct {
	Subject string
	Data    string
	Raw     *nats.Msg
}

type SubscribeCallback

type SubscribeCallback func(msg *SubjectMessage)

type SubscribeOption

type SubscribeOption func(subject string, cb SubscribeCallback) error

Jump to

Keyboard shortcuts

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