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
type Headers ¶
Headers represents message headers that can be used for both map operations and propagation
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 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 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)) }
Click to show internal directories.
Click to hide internal directories.