Documentation
¶
Index ¶
- Variables
- type AsyncPublishResult
- type AsyncResponse
- type BatchPublisher
- type BatchPublisherConfig
- type Client
- func (c *Client) Ack(ctx context.Context, m broker.Message) error
- func (c *Client) CancelTask(ctx context.Context, id, reason string) error
- func (c *Client) Command(ctx context.Context, subject string, payload any, response any, ...) error
- func (c *Client) CommitStreamOffset(ctx context.Context, stream, group string, offset uint64) error
- func (c *Client) CommitStreamTransaction(ctx context.Context, stream string, tx broker.StreamTransactionHTTPPayload) ([]broker.PublishResult, error)
- func (c *Client) Complete(ctx context.Context, m broker.Message, result any) error
- func (c *Client) Config() Config
- func (c *Client) Consumers(ctx context.Context) ([]broker.ConsumerInfo, error)
- func (c *Client) DLQ(ctx context.Context, queue string, limit int) ([]broker.Message, error)
- func (c *Client) Events(ctx context.Context, after string, wait time.Duration) ([]broker.Notification, error)
- func (c *Client) Extend(ctx context.Context, m broker.Message, d time.Duration) error
- func (c *Client) Fail(ctx context.Context, m broker.Message, e error) error
- func (c *Client) Heartbeat(ctx context.Context) (broker.ConsumerInfo, error)
- func (c *Client) Nack(ctx context.Context, m broker.Message, opts ...NackOption) error
- func (c *Client) NewBatchPublisher(cfg BatchPublisherConfig) *BatchPublisher
- func (c *Client) Poll(ctx context.Context, queue string, limit int) ([]broker.Message, error)
- func (c *Client) PollFrames(ctx context.Context, queue string, limit int) ([]broker.Message, error)
- func (c *Client) Progress(ctx context.Context, m broker.Message, p broker.Progress) error
- func (c *Client) Publish(ctx context.Context, topic string, payload any, opts ...PublishOption) (broker.PublishResult, error)
- func (c *Client) PublishAsync(ctx context.Context, topic string, payload any, opts ...PublishOption) <-chan AsyncPublishResult
- func (c *Client) PublishBatch(ctx context.Context, topic string, payloads []any, opts ...PublishOption) (broker.BatchPublishResult, error)
- func (c *Client) PublishFrame(ctx context.Context, msg broker.Message) (broker.PublishResult, error)
- func (c *Client) ReadStream(ctx context.Context, stream, group string, after uint64, limit int) ([]broker.Message, error)
- func (c *Client) Register(ctx context.Context, reg broker.ConsumerRegistration) (broker.ConsumerInfo, error)
- func (c *Client) Reject(ctx context.Context, m broker.Message, reason string) error
- func (c *Client) ReplayDLQ(ctx context.Context, queue string) error
- func (c *Client) Request(ctx context.Context, subject string, payload any, response any, ...) error
- func (c *Client) RequestAsync(ctx context.Context, subject string, payload any, response any, ...) <-chan AsyncResponse
- func (c *Client) Respond(ctx context.Context, m broker.Message, response any, ack bool) error
- func (c *Client) RespondError(ctx context.Context, m broker.Message, e error, ack bool) error
- func (c *Client) RetryTask(ctx context.Context, id string) error
- func (c *Client) StreamOffset(ctx context.Context, stream, group string) (uint64, error)
- func (c *Client) SubmitTask(ctx context.Context, name string, payload any, opts ...TaskOption) (broker.TaskInfo, error)
- func (c *Client) Subscribe(ctx context.Context, sub broker.RemoteSubscription) (broker.ConsumerInfo, error)
- func (c *Client) Task(ctx context.Context, id string) (broker.TaskInfo, error)
- func (c *Client) TaskResult(ctx context.Context, id string) (broker.TaskInfo, []byte, error)
- type Config
- type Delivery
- func (d Delivery) Ack(ctx context.Context) error
- func (d Delivery) Complete(ctx context.Context, result any) error
- func (d Delivery) Decode(out any) error
- func (d Delivery) Extend(ctx context.Context, v time.Duration) error
- func (d Delivery) Fail(ctx context.Context, err error) error
- func (d Delivery) Nack(ctx context.Context, opts ...NackOption) error
- func (d Delivery) Progress(ctx context.Context, p broker.Progress) error
- func (d Delivery) Reject(ctx context.Context, reason string) error
- func (d Delivery) Respond(ctx context.Context, response any, ack bool) error
- func (d Delivery) RespondError(ctx context.Context, err error, ack bool) error
- type Event
- type Handler
- type Hooks
- type MessageEvent
- type NackOption
- type NackOptions
- type NotificationEvent
- type PublishOption
- func WithCausationID(v string) PublishOption
- func WithContentType(v string) PublishOption
- func WithCorrelationID(v string) PublishOption
- func WithDeduplication(id string, window time.Duration) PublishOption
- func WithDelay(v time.Duration) PublishOption
- func WithHeaders(v map[string]string) PublishOption
- func WithIdempotencyKey(v string) PublishOption
- func WithKey(v string) PublishOption
- func WithMaxAttempts(v int) PublishOption
- func WithMessageID(v string) PublishOption
- func WithMetadata(v map[string]string) PublishOption
- func WithPriority(v int) PublishOption
- func WithProducerID(v string) PublishOption
- func WithQueue(v string) PublishOption
- func WithRoutingKey(v string) PublishOption
- func WithSchema(name, version string) PublishOption
- func WithStrategy(v broker.StrategyType) PublishOption
- func WithStream(v string) PublishOption
- func WithTTL(v time.Duration) PublishOption
- func WithTenantID(v string) PublishOption
- func WithTraceID(v string) PublishOption
- func WithType(v string) PublishOption
- type PublishOptions
- type RequestHandler
- type TaskHandler
- type TaskOption
- type TaskOptions
- type Worker
- func (w *Worker) Client() *Client
- func (w *Worker) HandleCommand(s string, h RequestHandler)
- func (w *Worker) HandleCommandQueue(s, queue string, h RequestHandler)
- func (w *Worker) HandlePattern(p string, h Handler)
- func (w *Worker) HandleQueue(q string, h Handler)
- func (w *Worker) HandleRequest(s string, h RequestHandler)
- func (w *Worker) HandleRequestQueue(s, queue string, h RequestHandler)
- func (w *Worker) HandleTask(n string, h TaskHandler)
- func (w *Worker) HandleTaskQueue(n, queue string, h TaskHandler)
- func (w *Worker) HandleTopic(t string, h Handler)
- func (w *Worker) Run(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
var ErrBatchPublisherClosed = errors.New("client: batch publisher closed")
ErrBatchPublisherClosed is returned by Publish after Close.
Functions ¶
This section is empty.
Types ¶
type AsyncPublishResult ¶
type AsyncPublishResult struct {
Result broker.PublishResult
Error error
}
type AsyncResponse ¶
type AsyncResponse struct {
Error error
}
type BatchPublisher ¶
type BatchPublisher struct {
// contains filtered or unexported fields
}
BatchPublisher turns many concurrent single-message Publish calls into a few frame-batch requests. Each caller still returns only after the broker has durably accepted its own message, with its own error, so durability and error semantics match one request per message while the request, header and fsync overhead is shared. There is no timer: while a batch is in flight, later messages accumulate and go out together, exactly like WAL group commit. A lone caller is sent immediately and never waits for company.
func (*BatchPublisher) Close ¶
func (p *BatchPublisher) Close()
Close stops accepting messages, sends everything already queued and waits.
type BatchPublisherConfig ¶
type BatchPublisherConfig struct {
// MaxBatch caps messages per request. Default 512.
MaxBatch int
// MaxInFlight is how many batch requests may be outstanding at once, so a
// new batch fills while earlier ones wait on the broker's fsync. Default 4.
MaxInFlight int
// QueueSize bounds messages waiting to be batched; Publish blocks (or
// honors ctx) when it is full. Default 8192.
QueueSize int
}
BatchPublisherConfig tunes request coalescing. Zero values pick defaults.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CancelTask ¶
func (*Client) CommitStreamOffset ¶
func (*Client) CommitStreamTransaction ¶
func (c *Client) CommitStreamTransaction(ctx context.Context, stream string, tx broker.StreamTransactionHTTPPayload) ([]broker.PublishResult, error)
CommitStreamTransaction publishes outputs and advances the input offset in one operation. ErrOffsetConflict means another commit changed the expected offset.
func (*Client) NewBatchPublisher ¶
func (c *Client) NewBatchPublisher(cfg BatchPublisherConfig) *BatchPublisher
NewBatchPublisher starts a coalescing publisher on top of c.
func (*Client) PollFrames ¶
func (*Client) Publish ¶
func (c *Client) Publish(ctx context.Context, topic string, payload any, opts ...PublishOption) (broker.PublishResult, error)
func (*Client) PublishAsync ¶
func (c *Client) PublishAsync(ctx context.Context, topic string, payload any, opts ...PublishOption) <-chan AsyncPublishResult
func (*Client) PublishBatch ¶
func (c *Client) PublishBatch(ctx context.Context, topic string, payloads []any, opts ...PublishOption) (broker.BatchPublishResult, error)
func (*Client) PublishFrame ¶
func (*Client) ReadStream ¶
func (*Client) Register ¶
func (c *Client) Register(ctx context.Context, reg broker.ConsumerRegistration) (broker.ConsumerInfo, error)
func (*Client) RequestAsync ¶
func (*Client) RespondError ¶
func (*Client) StreamOffset ¶
func (*Client) SubmitTask ¶
func (*Client) Subscribe ¶
func (c *Client) Subscribe(ctx context.Context, sub broker.RemoteSubscription) (broker.ConsumerInfo, error)
type Config ¶
type Config struct {
BrokerURL, Token, ConsumerID, Group, Name, Version string
BrokerURLs []string
Concurrency, MaxInFlight, PollLimit int
HeartbeatInterval, VisibilityTimeout, PollWait time.Duration
DisableAutoExtendLeases bool
LeaseExtensionInterval time.Duration
MaxLeaseExtensions int
HTTPClient *http.Client
Pool *fw.Pool
Hooks Hooks
FrameCodec broker.FrameCodec
// TLSCertFile is the path to the client TLS certificate for mTLS.
TLSCertFile string
// TLSKeyFile is the path to the client TLS private key for mTLS.
TLSKeyFile string
// TLSCACertFile is the path to the CA certificate to verify the server.
TLSCACertFile string
// InsecureSkipVerify skips server certificate verification (dev only).
InsecureSkipVerify bool
}
type Hooks ¶
type Hooks struct {
OnConnecting, OnConnected, OnAuthenticated, OnRegistered, OnSubscribed, OnPollStart, OnHeartbeat, OnReconnect, OnDrain, OnStopped func(Event)
OnNotification func(NotificationEvent)
OnMessageReceived, AfterHandle, OnHandlerError, OnAck, OnNack, OnReject, OnProgress, OnLeaseExtended func(MessageEvent)
BeforeHandle func(MessageEvent) error
}
func LoggingHooks ¶
LoggingHooks returns lifecycle hooks that log structured remote-consumer events.
func LoggingHooksWith ¶
type MessageEvent ¶
type NackOption ¶
type NackOption func(*NackOptions)
func NackDLQ ¶
func NackDLQ(v string) NackOption
func NackDelay ¶
func NackDelay(v time.Duration) NackOption
func NackError ¶
func NackError(v string) NackOption
func NackReason ¶
func NackReason(v string) NackOption
type NackOptions ¶
type NackOptions struct {
Action broker.NackAction
Delay time.Duration
DLQ, Reason, Error string
}
type NotificationEvent ¶
type NotificationEvent struct {
Notification broker.Notification
Time time.Time
}
type PublishOption ¶
type PublishOption func(*PublishOptions)
func WithCausationID ¶
func WithCausationID(v string) PublishOption
func WithContentType ¶
func WithContentType(v string) PublishOption
func WithCorrelationID ¶
func WithCorrelationID(v string) PublishOption
func WithDeduplication ¶
func WithDeduplication(id string, window time.Duration) PublishOption
func WithDelay ¶
func WithDelay(v time.Duration) PublishOption
func WithHeaders ¶
func WithHeaders(v map[string]string) PublishOption
func WithIdempotencyKey ¶
func WithIdempotencyKey(v string) PublishOption
func WithKey ¶
func WithKey(v string) PublishOption
func WithMaxAttempts ¶
func WithMaxAttempts(v int) PublishOption
func WithMessageID ¶
func WithMessageID(v string) PublishOption
func WithMetadata ¶
func WithMetadata(v map[string]string) PublishOption
func WithPriority ¶
func WithPriority(v int) PublishOption
func WithProducerID ¶
func WithProducerID(v string) PublishOption
func WithQueue ¶
func WithQueue(v string) PublishOption
func WithRoutingKey ¶
func WithRoutingKey(v string) PublishOption
func WithSchema ¶
func WithSchema(name, version string) PublishOption
func WithStrategy ¶
func WithStrategy(v broker.StrategyType) PublishOption
func WithStream ¶
func WithStream(v string) PublishOption
func WithTTL ¶
func WithTTL(v time.Duration) PublishOption
func WithTenantID ¶
func WithTenantID(v string) PublishOption
func WithTraceID ¶
func WithTraceID(v string) PublishOption
func WithType ¶
func WithType(v string) PublishOption
type PublishOptions ¶
type PublishOptions struct {
Queue, Stream, Type, Key, RoutingKey, TenantID, IdempotencyKey string
Headers, Metadata map[string]string
Priority int
ContentType string
Schema string
SchemaVersion string
MessageID string
CorrelationID string
CausationID string
TraceID string
DeduplicationID string
DeduplicationWindow time.Duration
TTL time.Duration
Delay time.Duration
MaxAttempts int
ProducerID string
Strategy broker.StrategyType
}
PublishOptions mirrors the broker's PublishOptions. It previously carried only seven fields, so the client could not reach content_type, schema, ttl, delay, trace propagation, deduplication, max_attempts or a producer-chosen message id, all of which the embedded API supported.
type TaskOption ¶
type TaskOption func(*TaskOptions)
func WithTaskMaxAttempts ¶
func WithTaskMaxAttempts(v int) TaskOption
func WithTaskMetadata ¶
func WithTaskMetadata(v map[string]string) TaskOption
func WithTaskPriority ¶
func WithTaskPriority(v int) TaskOption
func WithTaskQueue ¶
func WithTaskQueue(v string) TaskOption
func WithTaskTenantID ¶
func WithTaskTenantID(v string) TaskOption
type TaskOptions ¶
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
func (*Worker) HandleCommand ¶
func (w *Worker) HandleCommand(s string, h RequestHandler)
func (*Worker) HandleCommandQueue ¶
func (w *Worker) HandleCommandQueue(s, queue string, h RequestHandler)
func (*Worker) HandlePattern ¶
func (*Worker) HandleQueue ¶
func (*Worker) HandleRequest ¶
func (w *Worker) HandleRequest(s string, h RequestHandler)
func (*Worker) HandleRequestQueue ¶
func (w *Worker) HandleRequestQueue(s, queue string, h RequestHandler)
func (*Worker) HandleTask ¶
func (w *Worker) HandleTask(n string, h TaskHandler)
func (*Worker) HandleTaskQueue ¶
func (w *Worker) HandleTaskQueue(n, queue string, h TaskHandler)