Documentation
¶
Overview ¶
Package deadentity owns workspace-scoped failure streaks and durable dead-runtime recovery.
Index ¶
- Constants
- Variables
- func WithProbeRetry(ctx context.Context, key store.DeadEntityKey) context.Context
- type FailureClass
- type Option
- func WithClock(now func() time.Time) Option
- func WithEventStore(events store.EventSummaryStore) Option
- func WithLogger(logger *slog.Logger) Option
- func WithPermanentFailureThreshold(threshold int) Option
- func WithRecoveryInterval(interval time.Duration) Option
- func WithTransitionEventTimeout(timeout time.Duration) Option
- type ProbeDecision
- type Service
- func (s *Service) BeforeProbe(ctx context.Context, key store.DeadEntityKey) (ProbeDecision, error)
- func (s *Service) ForgetEntity(key store.DeadEntityKey)
- func (s *Service) ForgetWorkspace(workspaceID string)
- func (s *Service) List(ctx context.Context, workspaceID string) ([]store.DeadEntity, error)
- func (s *Service) RecordFailure(ctx context.Context, key store.DeadEntityKey, class FailureClass, ...) error
- func (s *Service) RecordSuccess(ctx context.Context, key store.DeadEntityKey) error
- func (s *Service) Status(ctx context.Context, key store.DeadEntityKey) (Status, error)
- type Status
Constants ¶
const ( DefaultPermanentFailureThreshold = 5 DefaultRecoveryInterval = time.Minute DefaultTransitionEventTimeout = 5 * time.Second )
Variables ¶
var ErrInvalidFailureClass = errors.New("deadentity: invalid failure class")
Functions ¶
func WithProbeRetry ¶
WithProbeRetry admits an explicit retry for one entity without claiming recovery before discovery succeeds.
Types ¶
type FailureClass ¶
type FailureClass uint8
FailureClass describes whether one failed attempt confirms a stable fault.
const ( FailureTransient FailureClass = iota FailurePermanent )
type Option ¶
type Option func(*Service)
Option configures a Service.
func WithEventStore ¶
func WithEventStore(events store.EventSummaryStore) Option
WithEventStore enables public transition summaries.
func WithLogger ¶
WithLogger injects the diagnostic logger used for fail-open persistence paths.
func WithPermanentFailureThreshold ¶
WithPermanentFailureThreshold overrides the production threshold for tests.
func WithRecoveryInterval ¶
WithRecoveryInterval overrides the production recovery interval for tests.
func WithTransitionEventTimeout ¶
WithTransitionEventTimeout bounds the detached write of one transition event.
type ProbeDecision ¶
ProbeDecision tells a runtime adapter whether it may contact an external entity.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service coordinates durable dead marks and opportunistic recovery attempts.
func New ¶
func New(deadStore store.DeadEntityStore, opts ...Option) *Service
New constructs a workspace-scoped dead-entity coordinator.
func (*Service) BeforeProbe ¶
func (s *Service) BeforeProbe(ctx context.Context, key store.DeadEntityKey) (ProbeDecision, error)
BeforeProbe admits ordinary live attempts and one due recovery attempt per interval.
func (*Service) ForgetEntity ¶
func (s *Service) ForgetEntity(key store.DeadEntityKey)
ForgetEntity retires one entity's in-memory state without changing durable state.
func (*Service) ForgetWorkspace ¶
ForgetWorkspace retires one workspace's in-memory dead-entity cache.
func (*Service) List ¶
List returns durable dead marks for one workspace for diagnostic projections.
func (*Service) RecordFailure ¶
func (s *Service) RecordFailure( ctx context.Context, key store.DeadEntityKey, class FailureClass, reason string, ) error
RecordFailure advances or resets the permanent-failure streak for one attempted probe.
func (*Service) RecordSuccess ¶
RecordSuccess clears a durable mark and restores ordinary admission.