event

package
v0.29.3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BotEventFire added in v0.23.1

func BotEventFire(ctx types.Context, eventName string, param types.KV) error

func NewMessage

func NewMessage(payload any) (*message.Message, error)

func NewPublisher

func NewPublisher() (message.Publisher, error)

func NewRouter

func NewRouter() (*message.Router, error)

func NewSubscriber

func NewSubscriber() (message.Subscriber, error)

func PublishMessage

func PublishMessage(ctx context.Context, topic string, payload any) error

func SendMessage

func SendMessage(ctx types.Context, msg types.MsgPayload) error

Types

type Retry added in v0.26.3

type Retry struct {
	// MaxRetries is maximum number of times a retry will be attempted.
	MaxRetries int

	// InitialInterval is the first interval between retries. Subsequent intervals will be scaled by Multiplier.
	InitialInterval time.Duration
	// MaxInterval sets the limit for the exponential backoff of retries. The interval will not be increased beyond MaxInterval.
	MaxInterval time.Duration
	// Multiplier is the factor by which the waiting interval will be multiplied between retries.
	Multiplier float64
	// MaxElapsedTime sets the time limit of how long retries will be attempted. Disabled if 0.
	MaxElapsedTime time.Duration
	// RandomizationFactor randomizes the spread of the backoff times within the interval of:
	// [currentInterval * (1 - randomization_factor), currentInterval * (1 + randomization_factor)].
	RandomizationFactor float64

	// OnRetryHook is an optional function that will be executed on each retry attempt.
	// The number of the current retry is passed as retryNum,
	OnRetryHook func(retryNum int, delay time.Duration)

	Logger watermill.LoggerAdapter
}

Retry provides a middleware that retries the handler if errors are returned. The retry behaviour is configurable, with exponential backoff and maximum elapsed time.

func (Retry) Middleware added in v0.26.3

func (r Retry) Middleware(h message.HandlerFunc) message.HandlerFunc

Middleware returns the Retry middleware.

Jump to

Keyboard shortcuts

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