Documentation
¶
Index ¶
- Variables
- type CircuitBreaker
- type CircuitBreakerHooks
- func (h CircuitBreakerHooks[T]) BeforeSend(ctx context.Context, cmd core.Cmd[T]) (context.Context, error)
- func (h CircuitBreakerHooks[T]) OnError(ctx context.Context, sentCmd SentCmd[T], err error)
- func (h CircuitBreakerHooks[T]) OnResult(ctx context.Context, sentCmd SentCmd[T], recvResult ReceivedResult, err error)
- func (h CircuitBreakerHooks[T]) OnTimeout(ctx context.Context, sentCmd SentCmd[T], err error)
- type CircuitBreakerHooksFactory
- type Hooks
- type HooksFactory
- type NoopHooks
- func (h NoopHooks[T]) BeforeSend(ctx context.Context, cmd core.Cmd[T]) (context.Context, error)
- func (h NoopHooks[T]) OnError(ctx context.Context, sentCmd SentCmd[T], err error)
- func (h NoopHooks[T]) OnResult(ctx context.Context, sentCmd SentCmd[T], recvResult ReceivedResult, err error)
- func (h NoopHooks[T]) OnTimeout(ctx context.Context, sentCmd SentCmd[T], err error)
- type NoopHooksFactory
- type ReceivedResult
- type SentCmd
Constants ¶
This section is empty.
Variables ¶
var ErrCircuitOpen = errors.New("circuit breaker is open")
ErrCircuitOpen is returned when an operation is attempted while the circuit breaker is in the open state.
Functions ¶
This section is empty.
Types ¶
type CircuitBreaker ¶
type CircuitBreaker interface { Open() bool Fail() Success() }
CircuitBreaker defines the interface for the Circuit Breaker pattern.
type CircuitBreakerHooks ¶
type CircuitBreakerHooks[T any] struct { // contains filtered or unexported fields }
CircuitBreakerHooks checks whether the circuit breaker is open before sending. If so, it returns ErrCircuitOpen, otherwise the corresponding method of the inner Hooks is called.
func NewCircuitBreakerHooks ¶
func NewCircuitBreakerHooks[T any](cb CircuitBreaker, hooks Hooks[T]) CircuitBreakerHooks[T]
NewCircuitBreakerHooks creates a new CircuitBreakerHooks.
func (CircuitBreakerHooks[T]) BeforeSend ¶
func (CircuitBreakerHooks[T]) OnError ¶
func (h CircuitBreakerHooks[T]) OnError(ctx context.Context, sentCmd SentCmd[T], err error)
func (CircuitBreakerHooks[T]) OnResult ¶
func (h CircuitBreakerHooks[T]) OnResult(ctx context.Context, sentCmd SentCmd[T], recvResult ReceivedResult, err error)
type CircuitBreakerHooksFactory ¶
type CircuitBreakerHooksFactory[T any] struct { // contains filtered or unexported fields }
CircuitBreakerHooksFactory can be used to create hooks that incorporate circuit breaker logic during the command sending process.
func NewCircuitBreakerHooksFactory ¶
func NewCircuitBreakerHooksFactory[T any](cb CircuitBreaker, factory HooksFactory[T]) CircuitBreakerHooksFactory[T]
NewCircuitBreakerHooksFactory creates a new CircuitBreakerHooksFactory.
func (CircuitBreakerHooksFactory[T]) New ¶
func (f CircuitBreakerHooksFactory[T]) New() Hooks[T]
type Hooks ¶
type Hooks[T any] interface { BeforeSend(ctx context.Context, cmd core.Cmd[T]) (context.Context, error) OnError(ctx context.Context, sentCmd SentCmd[T], err error) OnResult(ctx context.Context, sentCmd SentCmd[T], recvResult ReceivedResult, err error) OnTimeout(ctx context.Context, sentCmd SentCmd[T], err error) }
Hooks defines an interface for customizing behavior during the command sending process. Implementations can provide hooks for events such as BeforeSend, OnError, OnResult, and OnTimeout.
type HooksFactory ¶
HooksFactory provides a way to create new Hooks instances.
type NoopHooks ¶
type NoopHooks[T any] struct{}
func (NoopHooks[T]) BeforeSend ¶
type NoopHooksFactory ¶
type NoopHooksFactory[T any] struct { // contains filtered or unexported fields }
func (NoopHooksFactory[T]) New ¶
func (f NoopHooksFactory[T]) New() Hooks[T]
type ReceivedResult ¶
type ReceivedResult struct { Seq core.Seq Size int Result core.Result }