Documentation
¶
Overview ¶
Package breaker is a circuit breaker persisted in a state file, so short lived processes (hooks, CLI invocations) share one view of it.
Policy (same as the ralph bash/python transports):
- two consecutive failures open the breaker;
- HTTP 401/422 (config errors) open it immediately via Open;
- success resets the consecutive counter, but only while closed;
- once open it stays open until Reset.
Every mutation holds an exclusive file lock across read-modify-write and replaces the state file by atomic rename, so concurrent processes never lose an update and readers never see a torn file. Persistence is best effort: I/O errors never fail the caller; an unreadable file reads closed.
Index ¶
Constants ¶
const (
// FailureThreshold is the consecutive-failure count that opens the breaker.
FailureThreshold = 2
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Breaker ¶
type Breaker struct {
// contains filtered or unexported fields
}
Breaker is a file-backed circuit breaker. It satisfies jev.Breaker.
func (*Breaker) RecordFailure ¶
RecordFailure counts a failure and opens after FailureThreshold in a row. It is silent once open.
func (*Breaker) RecordSuccess ¶
func (b *Breaker) RecordSuccess()
RecordSuccess resets the failure counter. It does not close an open breaker.