eventing

package
v1.0.69 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotReplyable = errors.New("message is not replyable")
View Source
var ErrRequestTimeout = errors.New("request timed out")
View Source
var ReplyHeader = "reply-to"
View Source
var SubjectHeader = "subject"

Functions

This section is empty.

Types

type Client

type Client interface {
	// Publish publishes a message to a subject
	Publish(ctx context.Context, subject string, data []byte, opts ...PublishOption) error
	// QueuePublish publishes a message to a subject in a consumer group named queue
	QueuePublish(ctx context.Context, subject string, data []byte, opts ...PublishOption) error
	// Request requests a message from a subject, and synchronously waits for a reply. All subscribers will receive the message and try to reply. You probably want to use QueueRequest instead.
	Request(ctx context.Context, subject string, data []byte, timeout time.Duration, opts ...PublishOption) (Message, error)
	// QueueRequest requests a message from a subject in a consumer, and synchronously waits for a reply
	QueueRequest(ctx context.Context, subject string, data []byte, timeout time.Duration, opts ...PublishOption) (Message, error)
	// Subscribe subscribes to a subject
	Subscribe(ctx context.Context, subject string, cb MessageCallback) (Subscriber, error)
	// QueueSubscribe subscribes to a subject in a consumer group named queue
	QueueSubscribe(ctx context.Context, subject, queue string, cb MessageCallback) (Subscriber, error)
	// QueueFetchMessages fetches messages from a subject in a consumer group named queue, the messages must be acknowledged by calling the Ack method on the MessageSet
	QueueFetchMessages(ctx context.Context, subject, queue string, count int64) (MessageSet, error)
	// Close closes the client
	Close() error
}

Client defines the interface for event clients

func NewRedisClient

func NewRedisClient(ctx context.Context, logger logger.Logger, rdb *redis.Client) (Client, error)

type Headers

type Headers map[string]string

Headers represents message headers that can be used for both map operations and propagation

func (Headers) Get

func (h Headers) Get(key string) string

func (Headers) Keys

func (h Headers) Keys() []string

func (Headers) Set

func (h Headers) Set(key string, value string)

type Message

type Message interface {
	Data() []byte
	Headers() Headers
	Reply(ctx context.Context, data []byte, opts ...PublishOption) error
	Subject() string
}

Message represents a message received from the event system

type MessageCallback

type MessageCallback func(ctx context.Context, msg Message)

type MessageReplier added in v1.0.18

type MessageReplier func(ctx context.Context, data []byte, opts ...PublishOption) error

type MessageSet added in v1.0.29

type MessageSet interface {
	Messages() []Message
	Ack(ctx context.Context) error
}

type PublishOption

type PublishOption func(*publishOptions)

func WithHeader

func WithHeader(key, value string) PublishOption

func WithTrim added in v1.0.29

func WithTrim(trim int64) PublishOption

sets the trim publish option, which is the number of old messages to trim from the stream after the message is published

type Subscriber

type Subscriber interface {
	// Close stops the subscriber
	Close() error
	// IsValid returns true if the subscriber is running, false if it has been closed, or is nil or is otherwise not in a running state
	IsValid() bool
	// CloseWithCallback closes the subscriber and calls the callback with the error if there is one
	CloseWithCallback(ctx context.Context, cb func(err error))
}

Jump to

Keyboard shortcuts

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