-
Notifications
You must be signed in to change notification settings - Fork 24
/
circuit-iface.go
26 lines (21 loc) · 1.21 KB
/
circuit-iface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package runtime
import "github.com/fluxninja/aperture/v2/pkg/policies/controlplane/iface"
// TickEndCallback is a function that is called when a tick ends.
type TickEndCallback func(circuit CircuitAPI) error
// TickStartCallback is a function that is called when a tick starts.
type TickStartCallback func(circuit CircuitAPI) error
// CircuitAPI is for read only access to policy and scheduling of background jobs.
type CircuitAPI interface {
iface.Policy
// ScheduleConditionalBackgroundJob schedules a background job for one time execution. The job gets scheduled only if currentTick is a multiple of ticksPerExecution. There can be at most a single job with a certain name pending to be run at a time. Subsequent invocations with the same job name overwrite the previous one.
ScheduleConditionalBackgroundJob(backgroundJob BackgroundJob, ticksPerExecution int)
GetTickInfo() TickInfo
}
// CircuitSuperAPI is for read only access to policy, scheduling of background jobs and also provides methods for acquiring & releasing circuit execution lock.
type CircuitSuperAPI interface {
CircuitAPI
RegisterTickEndCallback(ec TickEndCallback)
RegisterTickStartCallback(sc TickStartCallback)
LockExecution()
UnlockExecution()
}