mqwrapper

package
v0.0.0-...-1593278 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 2 Imported by: 5

Documentation

Index

Constants

View Source
const DefaultPartitionIdx = 0

Variables

View Source
var ErrTopicNotExist = errors.New("topic not exist")

ErrTopicNotExist topic not exist error.

Functions

This section is empty.

Types

type Client

type Client interface {
	// CreateProducer creates a producer instance
	CreateProducer(options ProducerOptions) (Producer, error)

	// Subscribe creates a consumer instance and subscribe a topic
	Subscribe(options ConsumerOptions) (Consumer, error)

	// Get the earliest MessageID
	EarliestMessageID() MessageID

	// String to msg ID
	StringToMsgID(string) (MessageID, error)

	// Deserialize MessageId from a byte array
	BytesToMsgID([]byte) (MessageID, error)

	// Close the client and free associated resources
	Close()
}

Client is the interface that provides operations of message queues

type Consumer

type Consumer interface {
	// returns the subscription for the consumer
	Subscription() string

	// Get Message channel, once you chan you can not seek again
	Chan() <-chan Message

	// Seek to the uniqueID position
	Seek(MessageID, bool) error //nolint:govet

	// Ack make sure that msg is received
	Ack(Message)

	// Close consumer
	Close()

	// GetLatestMsgID return the latest message ID
	GetLatestMsgID() (MessageID, error)

	// check created topic whether vaild or not
	CheckTopicValid(channel string) error
}

Consumer is the interface that provides operations of a consumer

type ConsumerOptions

type ConsumerOptions struct {
	// The topic that this consumer will subscribe on
	Topic string

	// The subscription name for this consumer
	SubscriptionName string

	// InitialPosition at which the cursor will be set when subscribe
	// Default is `Latest`
	SubscriptionInitialPosition

	// Set receive channel size
	BufSize int64
}

ConsumerOptions contains the options of a consumer

type Message

type Message interface {
	// Topic get the topic from which this message originated from
	Topic() string

	// Properties are application defined key/value pairs that will be attached to the message.
	// Return the properties attached to the message.
	Properties() map[string]string

	// Payload get the payload of the message
	Payload() []byte

	// ID get the unique message ID associated with this message.
	// The message id can be used to univocally refer to a message without having the keep the entire payload in memory.
	ID() MessageID
}

Message is the interface that provides operations of a consumer

type MessageID

type MessageID interface {
	// Serialize the message id into a sequence of bytes that can be stored somewhere else
	Serialize() []byte

	AtEarliestPosition() bool

	LessOrEqualThan(msgID []byte) (bool, error)

	Equal(msgID []byte) (bool, error)
}

MessageID is the interface that provides operations of message is

type Producer

type Producer interface {

	// publish a message
	Send(ctx context.Context, message *ProducerMessage) (MessageID, error)

	Close()
}

Producer is the interface that provides operations of producer

type ProducerMessage

type ProducerMessage struct {
	// Payload get the payload of the message
	Payload []byte
	// Properties are application defined key/value pairs that will be attached to the message.
	// Return the properties attached to the message.
	Properties map[string]string
}

ProducerMessage contains the messages of a producer

type ProducerOptions

type ProducerOptions struct {
	// The topic that this Producer will publish
	Topic string

	// Enable compression
	// For Pulsar, this enables ZSTD compression with default compression level
	EnableCompression bool
}

ProducerOptions contains the options of a producer

type SubscriptionInitialPosition

type SubscriptionInitialPosition int

SubscriptionInitialPosition is the type of a subscription initial position

const (
	// SubscriptionPositionLatest is latest position which means the start consuming position will be the last message
	SubscriptionPositionLatest SubscriptionInitialPosition = iota

	// SubscriptionPositionEarliest is earliest position which means the start consuming position will be the first message
	SubscriptionPositionEarliest

	// SubscriptionPositionUnkown indicates we don't care about the consumer location, since we are doing another seek or only some meta api over that
	SubscriptionPositionUnknown
)

type UniqueID

type UniqueID = int64

UniqueID is the type of message id

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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