Documentation
¶
Index ¶
- Variables
- type CancelLocalFn
- type DurableEvictionCache
- func (c *DurableEvictionCache) FindKeyByStepRunID(stepRunID string) *string
- func (c *DurableEvictionCache) Get(key string) *DurableRunRecord
- func (c *DurableEvictionCache) GetAllWaiting() []*DurableRunRecord
- func (c *DurableEvictionCache) MarkActive(key string, now time.Time)
- func (c *DurableEvictionCache) MarkWaiting(key string, now time.Time, waitKind, resourceID string)
- func (c *DurableEvictionCache) RegisterRun(key, stepRunID string, invocationCount int, now time.Time, ...)
- func (c *DurableEvictionCache) SelectEvictionCandidate(now time.Time, durableSlots int, reserveSlots int, ...) string
- func (c *DurableEvictionCache) UnregisterRun(key string)
- type DurableEvictionConfig
- type DurableEvictionManager
- func (m *DurableEvictionManager) Cache() *DurableEvictionCache
- func (m *DurableEvictionManager) EvictAllWaiting(ctx context.Context) int
- func (m *DurableEvictionManager) HandleServerEviction(stepRunID string, invocationCount int)
- func (m *DurableEvictionManager) MarkActive(key string)
- func (m *DurableEvictionManager) MarkWaiting(key, waitKind, resourceID string)
- func (m *DurableEvictionManager) RegisterRun(key, stepRunID string, invocationCount int, policy *EvictionPolicy)
- func (m *DurableEvictionManager) Start()
- func (m *DurableEvictionManager) Stop()
- func (m *DurableEvictionManager) UnregisterRun(key string)
- type DurableRunRecord
- type EvictionCause
- type EvictionPolicy
- type RequestEvictionWithAckFn
Constants ¶
This section is empty.
Variables ¶
var DefaultDurableEvictionConfig = DurableEvictionConfig{ CheckInterval: 1 * time.Second, ReserveSlots: 0, MinWaitForCapacityEviction: 10 * time.Second, }
DefaultDurableEvictionConfig provides sensible defaults.
Functions ¶
This section is empty.
Types ¶
type CancelLocalFn ¶
type CancelLocalFn func(key string)
CancelLocalFn cancels a local durable run by its action key.
type DurableEvictionCache ¶
type DurableEvictionCache struct {
// contains filtered or unexported fields
}
DurableEvictionCache manages durable run state for eviction decisions. Thread-safe via internal mutex.
func NewDurableEvictionCache ¶
func NewDurableEvictionCache() *DurableEvictionCache
NewDurableEvictionCache creates a new empty cache.
func (*DurableEvictionCache) FindKeyByStepRunID ¶
func (c *DurableEvictionCache) FindKeyByStepRunID(stepRunID string) *string
FindKeyByStepRunID looks up a run key by its step run ID (linear scan).
func (*DurableEvictionCache) Get ¶
func (c *DurableEvictionCache) Get(key string) *DurableRunRecord
Get returns the run record for a given key, or nil if not found.
func (*DurableEvictionCache) GetAllWaiting ¶
func (c *DurableEvictionCache) GetAllWaiting() []*DurableRunRecord
GetAllWaiting returns all run records currently in a waiting state.
func (*DurableEvictionCache) MarkActive ¶
func (c *DurableEvictionCache) MarkActive(key string, now time.Time)
MarkActive decrements the wait reference count for a run.
func (*DurableEvictionCache) MarkWaiting ¶
func (c *DurableEvictionCache) MarkWaiting(key string, now time.Time, waitKind, resourceID string)
MarkWaiting increments the wait reference count for a run.
func (*DurableEvictionCache) RegisterRun ¶
func (c *DurableEvictionCache) RegisterRun( key, stepRunID string, invocationCount int, now time.Time, policy *EvictionPolicy, )
RegisterRun adds a run to the cache.
func (*DurableEvictionCache) SelectEvictionCandidate ¶
func (c *DurableEvictionCache) SelectEvictionCandidate( now time.Time, durableSlots int, reserveSlots int, minWaitForCapacityEviction time.Duration, ) string
SelectEvictionCandidate selects the best eviction candidate. Returns the key of the selected run, or empty string if none.
func (*DurableEvictionCache) UnregisterRun ¶
func (c *DurableEvictionCache) UnregisterRun(key string)
UnregisterRun removes a run from the cache.
type DurableEvictionConfig ¶
type DurableEvictionConfig struct {
CheckInterval time.Duration
ReserveSlots int
MinWaitForCapacityEviction time.Duration
}
DurableEvictionConfig controls the eviction manager behavior.
type DurableEvictionManager ¶
type DurableEvictionManager struct {
// contains filtered or unexported fields
}
DurableEvictionManager periodically checks for and evicts durable runs.
func NewDurableEvictionManager ¶
func NewDurableEvictionManager( durableSlots int, cancelLocal CancelLocalFn, requestEvict RequestEvictionWithAckFn, config DurableEvictionConfig, l *zerolog.Logger, ) *DurableEvictionManager
NewDurableEvictionManager creates a new eviction manager.
func (*DurableEvictionManager) Cache ¶
func (m *DurableEvictionManager) Cache() *DurableEvictionCache
Cache returns the underlying cache for direct access.
func (*DurableEvictionManager) EvictAllWaiting ¶
func (m *DurableEvictionManager) EvictAllWaiting(ctx context.Context) int
EvictAllWaiting evicts every currently-waiting durable run. Used during graceful shutdown.
func (*DurableEvictionManager) HandleServerEviction ¶
func (m *DurableEvictionManager) HandleServerEviction(stepRunID string, invocationCount int)
HandleServerEviction processes a server-initiated eviction notification.
func (*DurableEvictionManager) MarkActive ¶
func (m *DurableEvictionManager) MarkActive(key string)
MarkActive marks a run as active (no longer waiting).
func (*DurableEvictionManager) MarkWaiting ¶
func (m *DurableEvictionManager) MarkWaiting(key, waitKind, resourceID string)
MarkWaiting marks a run as waiting.
func (*DurableEvictionManager) RegisterRun ¶
func (m *DurableEvictionManager) RegisterRun(key, stepRunID string, invocationCount int, policy *EvictionPolicy)
RegisterRun adds a run to the eviction cache.
func (*DurableEvictionManager) Start ¶
func (m *DurableEvictionManager) Start()
Start begins the eviction check loop. Safe to call multiple times.
func (*DurableEvictionManager) Stop ¶
func (m *DurableEvictionManager) Stop()
Stop halts the eviction check loop.
func (*DurableEvictionManager) UnregisterRun ¶
func (m *DurableEvictionManager) UnregisterRun(key string)
UnregisterRun removes a run from the eviction cache.
type DurableRunRecord ¶
type DurableRunRecord struct {
RegisteredAt time.Time
EvictionPolicy *EvictionPolicy
WaitingSince *time.Time
Key string
StepRunID string
WaitKind string
WaitResourceID string
EvictionReason string
InvocationCount int
// contains filtered or unexported fields
}
DurableRunRecord tracks the state of a durable run for eviction decisions.
func (*DurableRunRecord) GetWaitingSince ¶
func (r *DurableRunRecord) GetWaitingSince() *time.Time
GetWaitingSince returns a copy of the waiting since timestamp.
func (*DurableRunRecord) IsWaiting ¶
func (r *DurableRunRecord) IsWaiting() bool
IsWaiting returns true if the run is currently in a waiting state.
func (*DurableRunRecord) WaitCount ¶
func (r *DurableRunRecord) WaitCount() int
WaitCount returns the current wait reference count.
type EvictionCause ¶
type EvictionCause string
const ( EvictionCauseTTLExceeded EvictionCause = "ttl_exceeded" EvictionCauseCapacityPressure EvictionCause = "capacity_pressure" EvictionCauseWorkerShutdown EvictionCause = "worker_shutdown" )
type EvictionPolicy ¶
EvictionPolicy mirrors the SDK-level EvictionPolicy for internal use.
type RequestEvictionWithAckFn ¶
type RequestEvictionWithAckFn func(ctx context.Context, key string, rec *DurableRunRecord) error
RequestEvictionWithAckFn sends an eviction request to the server and waits for ack.