nats

package
v0.0.0-...-37de26c Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn nats.Conn

A Conn represents a bare connection to a nats-server. It can send and receive []byte payloads. It is a type definition of nats.Conn

func NewNatClient

func NewNatClient(ctx context.Context, url string) (*Conn, error)

NewNatClient creates a NATS client that connect to given url

func (*Conn) Disconnect

func (c *Conn) Disconnect(ctx context.Context) error

Disconnect drains and closes the connection

func (*Conn) Flush

func (c *Conn) Flush() error

func (*Conn) Publish

func (c *Conn) Publish(ctx context.Context, topic string, data []byte) error

Publish publishes given data to a topic

func (*Conn) QueueSubscribe

func (c *Conn) QueueSubscribe(ctx context.Context, sub, group string, cb func(msg *Msg)) error

QueueSubscribe to a topic, given callback function

func (*Conn) Request

func (c *Conn) Request(ctx context.Context, sub string, data []byte,
	timeout time.Duration) (*Msg, error)

Request will send a request payload and deliver the response message, or an error, including a timeout if no message was received correctly

func (*Conn) Subscribe

func (c *Conn) Subscribe(ctx context.Context, topic string, cb func(msg *Msg)) error

Subscribe to a topic, given callback function

type Msg

type Msg struct {
	nats.Msg
}

Msg is a structure used by Subscribers and PublishMsg()

Jump to

Keyboard shortcuts

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