eventing

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotReplyable = errors.New("message is not replyable")

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)
	// Close closes the client
	Close() error
}

Client defines the interface for event clients

func NewRedisClient

func NewRedisClient(ctx context.Context, 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
}

Message represents a message received from the event system

type MessageCallback

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

type PublishOption

type PublishOption func(*publishOptions)

func WithHeader

func WithHeader(key, value string) PublishOption

type Subscriber

type Subscriber interface {
	// Close stops the subscriber
	Close() error
}

Jump to

Keyboard shortcuts

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