ws

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 10 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 {
	URL string
	// contains filtered or unexported fields
}

Client is a client for Apache Pulsar Websocket API. Use New to initialize the client with the default configuration.

func New

func New(url string) *Client

New initializes a new client.

func (*Client) Consumer

func (c *Client) Consumer(topic string, name string, params Params) (Consumer, error)

Consumer initializes a new consumer.

func (*Client) Producer

func (c *Client) Producer(topic string, params Params) (Producer, error)

Producer initializes a new producer.

func (*Client) Reader

func (c *Client) Reader(topic string, params Params) (Reader, error)

Reader initializes a new reader.

type Consumer

type Consumer interface {
	Receive(context.Context) (*Msg, error)
	Ack(context.Context, *Msg) error
	Nack(context.Context, *Msg) error
	Close() error
}

type Msg

type Msg struct {
	// MsgId is a base64-encoded value of the serializable MessageId proto.
	MsgId string `json:"messageId"`

	// Payload is the message payload.
	Payload []byte `json:"payload"`

	// PublishTime is the time the message was published.
	PublishTime time.Time `json:"publishTime"`

	// Properties are an arbitrary set of key-value properties.
	Properties map[string]string `json:"properties"`

	// Key is the partition key for this message.
	Key string `json:"key"`
}

type Params

type Params map[string]string

type Producer

type Producer interface {
	Send(context.Context, *PublishMsg) (*PublishResult, error)
	Close() error
}

type PublishError

type PublishError struct {
	Code    string `json:"code"`
	Msg     string `json:"msg"`
	Context string `json:"context"`
}

PublishError is the error type used if the server responds with an error.

func (*PublishError) Error

func (e *PublishError) Error() string

Error implements the error interface.

type PublishMsg

type PublishMsg struct {
	Payload             []byte            `json:"payload"`
	Properties          map[string]string `json:"properties"`
	Context             string            `json:"context"`
	Key                 string            `json:"key"`
	ReplicationClusters []string          `json:"replicationClusters"`
}

PublishMsg is the message type for publishing a new message.

type PublishResult

type PublishResult struct {
	MsgId   string `json:"messageId"`
	Context string `json:"context"`
}

PublishResult is the result of a successful publish.

type Reader

type Reader interface {
	Receive(context.Context) (*Msg, error)
	Ack(context.Context, *Msg) error
	Close() error
}

Jump to

Keyboard shortcuts

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