Documentation
¶
Index ¶
- Variables
- type CircuitBreaker
- type Manager
- type Option
- func WithEnabled(enabled bool) Option
- func WithFailureRateThreshold(failureRateThreshold int) Option
- func WithFlushInterval(flushInterval time.Duration) Option
- func WithMinimumRequestThreshold(minimumRequestThreshold int) Option
- func WithNowFunc(now func() time.Time) Option
- func WithRedisClient(client *redis.Client) Option
- func WithTimeWindowSize(seconds int) Option
- type Recorder
- type State
- type TimeBucketMetric
- type Unit
Constants ¶
This section is empty.
Variables ¶
View Source
var (
DefaultFlushInterval = defaultFlushInterval
)
Functions ¶
This section is empty.
Types ¶
type CircuitBreaker ¶
type CircuitBreaker interface {
// Name returns CircuitBreaker name
Name() string
// State returns CircuitBreaker State
State() State
// Metric returns CircuitBreaker metric
Metric() TimeBucketMetric
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) GetCircuitBreaker ¶
type Option ¶
type Option func(m *Manager)
func WithEnabled ¶
func WithFlushInterval ¶
func WithNowFunc ¶
func WithRedisClient ¶
func WithTimeWindowSize ¶
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
func NewRecorder ¶
func (*Recorder) Aggregate ¶
func (r *Recorder) Aggregate(unit Unit, from, to int64) []TimeBucketMetric
func (*Recorder) SetLastSync ¶
type TimeBucketMetric ¶
type TimeBucketMetric struct {
Start int64 `json:"start"`
Until int64 `json:"until"`
Success int64 `json:"success"`
Error int64 `json:"error"`
}
TimeBucketMetric represents aggregated metrics over the time interval [Start, Until).
func (TimeBucketMetric) FailureRate ¶
func (m TimeBucketMetric) FailureRate() float64
func (TimeBucketMetric) TotalRequest ¶
func (m TimeBucketMetric) TotalRequest() int64
Click to show internal directories.
Click to hide internal directories.