deadentity

package
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package deadentity owns workspace-scoped failure streaks and durable dead-runtime recovery.

Index

Constants

View Source
const (
	DefaultPermanentFailureThreshold = 5
	DefaultRecoveryInterval          = time.Minute
	DefaultTransitionEventTimeout    = 5 * time.Second
)

Variables

View Source
var ErrInvalidFailureClass = errors.New("deadentity: invalid failure class")

Functions

This section is empty.

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 WithClock

func WithClock(now func() time.Time) Option

WithClock injects the service clock.

func WithEventStore

func WithEventStore(events store.EventSummaryStore) Option

WithEventStore enables public transition summaries.

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger injects the diagnostic logger used for fail-open persistence paths.

func WithPermanentFailureThreshold

func WithPermanentFailureThreshold(threshold int) Option

WithPermanentFailureThreshold overrides the production threshold for tests.

func WithRecoveryInterval

func WithRecoveryInterval(interval time.Duration) Option

WithRecoveryInterval overrides the production recovery interval for tests.

func WithTransitionEventTimeout

func WithTransitionEventTimeout(timeout time.Duration) Option

WithTransitionEventTimeout bounds the detached write of one transition event.

type ProbeDecision

type ProbeDecision struct {
	Allowed  bool
	Recovery bool
	Dead     bool
	Reason   string
	MarkedAt time.Time
}

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

func (s *Service) ForgetWorkspace(workspaceID string)

ForgetWorkspace retires one workspace's in-memory dead-entity cache.

func (*Service) List

func (s *Service) List(ctx context.Context, workspaceID string) ([]store.DeadEntity, error)

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

func (s *Service) RecordSuccess(ctx context.Context, key store.DeadEntityKey) error

RecordSuccess clears a durable mark and restores ordinary admission.

func (*Service) Status

func (s *Service) Status(ctx context.Context, key store.DeadEntityKey) (Status, error)

Status returns dead state without consuming a due recovery attempt.

type Status

type Status struct {
	Dead     bool
	Reason   string
	MarkedAt time.Time
}

Status is the read-only dead state for one runtime entity.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL