Documentation
¶
Index ¶
Constants ¶
View Source
const ( ThresholdCount = "COUNT" ThresholdPercentage = "PERCENTAGE" ThresholdConsecutive = "CONSECUTIVE" )
threshold type can be only COUNT or PERCENTAGE ThresholdCount represents a threshold type based on count.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackEvent ¶ added in v1.0.3
CallbackEvent represents an event callback for the circuit.
type Circuit ¶ added in v1.0.3
type Circuit interface {
UpdateStatus(success bool)
IsCircuitOpen() bool
Data() CircuitData
}
Circuit represents a monitoring entity that tracks the status of a circuit.
func ConfigureCircuit ¶ added in v1.0.3
func ConfigureCircuit(monitorOptions CircuitOptions) (Circuit, error)
ConfigureCircuit creates and configures a new Circuit with the provided options.
type CircuitData ¶ added in v1.0.3
type CircuitImplementation ¶ added in v1.0.3
type CircuitImplementation struct {
Options CircuitOptions
FailureCount int64 // Number of failures recorded
SuccessCount int64 // Number of successes recorded
CircuitOpen bool // Indicates whether the circuit is open or closed
LastCapturedAt int64 // Timestamp of the last captured event
CircuitOpenedSince int64 // Timestamp when the circuit was opened
ConsecutiveCounter int64
Ticker *time.Ticker
Mutex sync.Mutex
XMutex sync.Mutex
}
CircuitImplementation represents the implementation of the Circuit interface.
func (*CircuitImplementation) Data ¶ added in v1.0.3
func (m *CircuitImplementation) Data() CircuitData
func (*CircuitImplementation) IsCircuitOpen ¶ added in v1.0.3
func (m *CircuitImplementation) IsCircuitOpen() bool
IsCircuitOpen returns true if the circuit is open, false otherwise.
func (*CircuitImplementation) UpdateStatus ¶ added in v1.0.3
func (m *CircuitImplementation) UpdateStatus(success bool)
UpdateStatus updates the status of the Circuit based on the success of the event.
type CircuitOptions ¶ added in v1.0.3
type CircuitOptions struct {
Name string // Name of the circuit
Threshold float32 // Threshold value for triggering circuit open
ThresholdType string // Type of threshold (e.g., percentage, count)
MinimumCount int64 // Minimum number of events required for monitoring
IntervalInSeconds int // Interval in seconds for monitoring (should be non-zero and multiple of 60)
OnCircuitOpen func(t CallbackEvent)
OnCircuitClosed func(t CallbackEvent)
}
CircuitOptions represents options for configuring a Circuit.
Click to show internal directories.
Click to hide internal directories.