client

package
v0.0.0-...-a506a69 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	UserID         string
	Password       string
	MaxMessageSize int
}

Config is client config.

type Conn

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

Conn represents a connection to a message broker.

func Dial

func Dial(ctx context.Context, address string, tlsConf *tls.Config, config *Config) (*Conn, error)

Dial connects to the message broker.

func (*Conn) CreatePublishStream

func (c *Conn) CreatePublishStream(ctx context.Context, topic string) (*PublishStream, error)

CreatePublishStream creates publish stream.

func (*Conn) SetLogger

func (c *Conn) SetLogger(logger *log.Logger)

SetLogger is setter for logger.

func (*Conn) Subscribe

func (c *Conn) Subscribe(ctx context.Context, topic string, count int) (*SubscribeStream, error)

Subscribe subscribes to a topic.

type PublishFlag

type PublishFlag byte

PublishFlag is meta information attached to the message to be published.

const (
	Buffered PublishFlag = iota + 1
	Unbuffered
)

Publish flags

type PublishStream

type PublishStream struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

PublishStream is a stream for publish message.

func (*PublishStream) Close

func (s *PublishStream) Close() error

Close closes the stream.

func (*PublishStream) Publish

func (s *PublishStream) Publish(data []byte, flag PublishFlag) error

Publish publishes message.

type SubscribeStream

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

SubscribeStream is a subscription stream.

func (*SubscribeStream) Close

func (c *SubscribeStream) Close() error

Close closes the stream.

func (*SubscribeStream) Done

func (c *SubscribeStream) Done() <-chan struct{}

Done channel for cancellation.

func (*SubscribeStream) Receive

func (c *SubscribeStream) Receive() <-chan []byte

Receive returns received message.

func (*SubscribeStream) Topic

func (c *SubscribeStream) Topic() string

Topic is a subscribed topic.

Jump to

Keyboard shortcuts

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