callbackhandler

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEventHandler

func NewEventHandler[T any](opts ...Option[T]) event.EventHandler[T]

NewEventHandler creates a new event.EventHandler that sends callbacks based on the success or failure of an event.

  • This handler supports internal logging; if a custom logger is provided via WithLogger, it will be used; otherwise, it will try to extract a logger from the context, and if none is found, a default logger will be used.

Types

type CallbackEventMessage

type CallbackEventMessage[T any] struct {
	event.BaseEventMessage[T]
	Callback *CallbackInfo `json:"callback"`
}

func (*CallbackEventMessage[T]) GetCallback

func (m *CallbackEventMessage[T]) GetCallback() *CallbackInfo

type CallbackInfo

type CallbackInfo struct {
	SuccessURL string `json:"success_url"`
	FailURL    string `json:"fail_url"`
}

type Option

type Option[T any] func(*callbackEventHandler[T])

Option is a function that configures an EventHandler

func WithCallbackConfig

func WithCallbackConfig[T any](maxRetries int, retryInterval, callbackTimeout time.Duration) Option[T]

WithCallbackConfig sets the callback configuration

func WithHTTPClient

func WithHTTPClient[T any](client *http.Client) Option[T]

WithHTTPClient sets a custom http.Client

func WithLogger

func WithLogger[T any](customLogger common_logger.Logger) Option[T]

WithLogger sets a custom logger.Logger implementation for the EventHandler. If not provided, the logger will be extracted from the context or a default will be used.

Jump to

Keyboard shortcuts

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