client

package
v0.10.3-0...-f06509b Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalHeader

func MarshalHeader(header *commonpb.MsgHeader) ([]byte, error)

func UnmarshalHeader

func UnmarshalHeader(headerbyte []byte) (*commonpb.MsgHeader, error)

Types

type Client

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

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

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

Client is the interface rocksmq client

func NewClient

func NewClient(options Options) (Client, error)

NewClient returns a rocksmq client

type Consumer

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

	// returns the topic for the consumer
	Topic() string

	// Signal channel
	MsgMutex() chan struct{}

	// Message channel
	Chan() <-chan mqwrapper.Message

	// Seek to the uniqueID position
	Seek(UniqueID) error //nolint:govet

	// Close consumer
	Close()

	// GetLatestMsgID get the latest msgID
	GetLatestMsgID() (int64, error)

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

Consumer interface provide operations for 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`
	mqwrapper.SubscriptionInitialPosition

	// Message for this consumer
	// When a message is received, it will be pushed to this channel for consumption
	MessageChannel chan mqwrapper.Message
}

ConsumerOptions is the options of a consumer

type Error

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

Error is a struct contains error msg and result

func (*Error) Error

func (e *Error) Error() string

Error returns the error message

func (*Error) Result

func (e *Error) Result() Result

Result returns the error result

type Options

type Options struct {
	Server RocksMQ
}

ClientOptions is the options of a client

type Producer

type Producer interface {
	// return the topic which producer is publishing to
	Topic() string

	// publish a message
	Send(message *mqwrapper.ProducerMessage) (UniqueID, error)

	// Close a producer
	Close()
}

Producer provedes some operations for a producer

type ProducerOptions

type ProducerOptions struct {
	Topic string
}

ProducerOptions is the options of a producer

type Result

type Result int

Result is the type of int and represent error result

const (
	Ok Result = iota
	UnknownError
	InvalidConfiguration
)

constant value used in error struct

type RmqMessage

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

rmqMessage wraps the message for rocksmq

func (*RmqMessage) ID

func (rm *RmqMessage) ID() mqwrapper.MessageID

ID returns the id of rocksmq message

func (*RmqMessage) Payload

func (rm *RmqMessage) Payload() []byte

Payload returns the payload of rocksmq message

func (*RmqMessage) Properties

func (rm *RmqMessage) Properties() map[string]string

Properties returns the properties of rocksmq message

func (*RmqMessage) Topic

func (rm *RmqMessage) Topic() string

Topic returns the topic name of rocksmq message

type RocksMQ

type RocksMQ = server.RocksMQ

RocksMQ is the type server.RocksMQ

type UniqueID

type UniqueID = server.UniqueID

UniqueID is the type of message ID

func EarliestMessageID

func EarliestMessageID() UniqueID

EarliestMessageID is used to get the earliest message ID, default -1

Jump to

Keyboard shortcuts

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