1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-06 22:06:19 +02:00

30 lines
801 B
Go
Raw Normal View History

2021-09-13 16:23:26 +08:00
package hystrix
import "context"
// Options represents hystrix client wrapper options
type Options struct {
// Filter used to prevent errors from trigger circuit breaker.
// return true if you want to ignore target error
Filter func(context.Context, error) bool
// Fallback used to define some code to execute during outages.
2021-09-13 16:23:26 +08:00
Fallback func(context.Context, error) error
}
// Option represents options update func
type Option func(*Options)
// WithFilter used to set filter func for options
func WithFilter(filter func(context.Context, error) bool) Option {
2021-09-13 16:23:26 +08:00
return func(o *Options) {
o.Filter = filter
}
}
// WithFallback used to set fallback func for options
func WithFallback(fallback func(context.Context, error) error) Option {
return func(o *Options) {
o.Fallback = fallback
}
}