invariant

package
v1.2.11-prerelease7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package invariant is a generated GoMock package.

Index

Constants

View Source
const (
	// CheckResultTypeFailed indicates a failure occurred while attempting to run check
	CheckResultTypeFailed CheckResultType = "failed"
	// CheckResultTypeCorrupted indicates check successfully ran and detected a corruption
	CheckResultTypeCorrupted CheckResultType = "corrupted"
	// CheckResultTypeHealthy indicates check successfully ran and detected no corruption
	CheckResultTypeHealthy CheckResultType = "healthy"

	// FixResultTypeSkipped indicates that fix skipped execution
	FixResultTypeSkipped FixResultType = "skipped"
	// FixResultTypeFixed indicates that fix successfully fixed an execution
	FixResultTypeFixed FixResultType = "fixed"
	// FixResultTypeFailed indicates that fix attempted to fix an execution but failed to do so
	FixResultTypeFailed FixResultType = "failed"

	// HistoryExists asserts that history must exist if concrete execution exists
	HistoryExists Name = "history_exists"

	// InactiveDomainExists asserts that if domain status is not registered that it's inactive
	InactiveDomainExists Name = "inactive_domain_exists"

	// OpenCurrentExecution asserts that an open concrete execution must have a valid current execution
	OpenCurrentExecution Name = "open_current_execution"
	// ConcreteExecutionExists asserts that an open current execution must have a valid concrete execution
	ConcreteExecutionExists Name = "concrete_execution_exists"

	// StaleWorkflow checks for workflows that exist beyond their retention window,
	// implying a failed cleanup / lost timers / etc of some kind.
	StaleWorkflow Name = "stale_workflow"

	// CollectionMutableState is the collection of invariants relating to mutable state
	CollectionMutableState Collection = 0
	// CollectionHistory is the collection  of invariants relating to history
	CollectionHistory Collection = 1
	// CollectionDomain is the collection  of invariants relating to domain status
	CollectionDomain Collection = 2
	// CollectionStale contains the stale workflow scanner
	CollectionStale Collection = 3
)
View Source
const TimerInvalidName = "TimerInvalid"

Variables

This section is empty.

Functions

func CollectionStrings added in v0.16.0

func CollectionStrings() []string

CollectionStrings returns a slice of all String values of the enum

func ExecutionOpen

func ExecutionOpen(execution interface{}) bool

ExecutionOpen returns true if execution state is open false if workflow is closed

func ExecutionStillExists

func ExecutionStillExists(
	ctx context.Context,
	exec *entity.Execution,
	pr persistence.Retryer,
	dc cache.DomainCache,
) (bool, error)

ExecutionStillExists returns true if execution still exists in persistence, false otherwise. Returns error on failure to confirm.

func ExecutionStillOpen

func ExecutionStillOpen(
	ctx context.Context,
	exec *entity.Execution,
	pr persistence.Retryer,
	dc cache.DomainCache,
) (bool, error)

ExecutionStillOpen returns true if execution in persistence exists and is open, false otherwise. Returns error on failure to confirm.

func Open

func Open(state int) bool

Open returns true if workflow state is open false if workflow is closed

Types

type CheckResult

type CheckResult struct {
	CheckResultType CheckResultType
	InvariantName   Name
	Info            string
	InfoDetails     string
}

CheckResult is the result of running Check.

type CheckResultType

type CheckResultType string

CheckResultType is the result type of running an invariant check

type Collection

type Collection int

Collection is a type which indicates a collection of invariants

func CollectionString added in v0.16.0

func CollectionString(s string) (Collection, error)

CollectionString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func CollectionValues added in v0.16.0

func CollectionValues() []Collection

CollectionValues returns all values of the enum

func (Collection) IsACollection added in v0.16.0

func (i Collection) IsACollection() bool

IsACollection returns "true" if the value is listed in the enum definition. "false" otherwise

func (Collection) String added in v0.16.0

func (i Collection) String() string

type FixResult

type FixResult struct {
	FixResultType FixResultType
	InvariantName Name
	CheckResult   CheckResult
	Info          string
	InfoDetails   string
}

FixResult is the result of running Fix.

func DeleteExecution

func DeleteExecution(
	ctx context.Context,
	exec interface{},
	pr persistence.Retryer,
	dc cache.DomainCache,
) *FixResult

DeleteExecution deletes concrete execution and current execution conditionally on matching runID.

type FixResultType

type FixResultType string

FixResultType is the result type of running an invariant fix

type Invariant

type Invariant interface {
	Check(context.Context, interface{}) CheckResult
	Fix(context.Context, interface{}) FixResult
	Name() Name
}

Invariant represents an invariant of a single execution. It can be used to check that the execution satisfies the invariant. It can also be used to fix the invariant for an execution.

func NewConcreteExecutionExists

func NewConcreteExecutionExists(
	pr persistence.Retryer, cache cache.DomainCache,
) Invariant

NewConcreteExecutionExists returns a new invariant for checking concrete execution

func NewHistoryExists

func NewHistoryExists(
	pr persistence.Retryer, dc cache.DomainCache,
) Invariant

func NewInactiveDomainExists added in v1.2.1

func NewInactiveDomainExists(
	pr persistence.Retryer, dc cache.DomainCache,
) Invariant

func NewOpenCurrentExecution

func NewOpenCurrentExecution(
	pr persistence.Retryer, dc cache.DomainCache,
) Invariant

NewOpenCurrentExecution returns a new invariant for checking open current execution

func NewStaleWorkflow added in v1.2.5

func NewStaleWorkflow(
	pr persistence.Retryer, dc cache.DomainCache, log *zap.Logger,
) Invariant

NewStaleWorkflow checks to see if a workflow has out-lived its retention window. This primarily asserts that that now < (min(start + execution timeout, min) + (domain retention*2)). If a workflow fails this check, its data is still lingering well beyond when it should have been cleaned up.

func NewTimerInvalid added in v0.18.0

func NewTimerInvalid(
	pr persistence.Retryer, cache cache.DomainCache,
) Invariant

NewTimerInvalid returns a new history exists invariant

type Manager

type Manager interface {
	RunChecks(context.Context, interface{}) ManagerCheckResult
	RunFixes(context.Context, interface{}) ManagerFixResult
}

Manager represents a manager of several invariants. It can be used to run a group of invariant checks or fixes.

func NewInvariantManager

func NewInvariantManager(
	invariants []Invariant,
) Manager

NewInvariantManager handles running a collection of invariants according to the invariant collection provided.

type ManagerCheckResult

type ManagerCheckResult struct {
	CheckResultType          CheckResultType
	DeterminingInvariantType *Name
	CheckResults             []CheckResult
}

ManagerCheckResult is the result of running a list of checks

type ManagerFixResult

type ManagerFixResult struct {
	FixResultType            FixResultType
	DeterminingInvariantName *Name
	FixResults               []FixResult
}

ManagerFixResult is the result of running a list of fixes

type MockInvariant

type MockInvariant struct {
	// contains filtered or unexported fields
}

MockInvariant is a mock of Invariant interface.

func NewMockInvariant

func NewMockInvariant(ctrl *gomock.Controller) *MockInvariant

NewMockInvariant creates a new mock instance.

func (*MockInvariant) Check

func (m *MockInvariant) Check(arg0 context.Context, arg1 interface{}) CheckResult

Check mocks base method.

func (*MockInvariant) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockInvariant) Fix

func (m *MockInvariant) Fix(arg0 context.Context, arg1 interface{}) FixResult

Fix mocks base method.

func (*MockInvariant) Name

func (m *MockInvariant) Name() Name

Name mocks base method.

type MockInvariantMockRecorder

type MockInvariantMockRecorder struct {
	// contains filtered or unexported fields
}

MockInvariantMockRecorder is the mock recorder for MockInvariant.

func (*MockInvariantMockRecorder) Check

func (mr *MockInvariantMockRecorder) Check(arg0, arg1 interface{}) *gomock.Call

Check indicates an expected call of Check.

func (*MockInvariantMockRecorder) Fix

func (mr *MockInvariantMockRecorder) Fix(arg0, arg1 interface{}) *gomock.Call

Fix indicates an expected call of Fix.

func (*MockInvariantMockRecorder) Name added in v0.16.0

Name indicates an expected call of Name.

type MockManager

type MockManager struct {
	// contains filtered or unexported fields
}

MockManager is a mock of Manager interface.

func NewMockManager

func NewMockManager(ctrl *gomock.Controller) *MockManager

NewMockManager creates a new mock instance.

func (*MockManager) EXPECT

func (m *MockManager) EXPECT() *MockManagerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockManager) RunChecks

func (m *MockManager) RunChecks(arg0 context.Context, arg1 interface{}) ManagerCheckResult

RunChecks mocks base method.

func (*MockManager) RunFixes

func (m *MockManager) RunFixes(arg0 context.Context, arg1 interface{}) ManagerFixResult

RunFixes mocks base method.

type MockManagerMockRecorder

type MockManagerMockRecorder struct {
	// contains filtered or unexported fields
}

MockManagerMockRecorder is the mock recorder for MockManager.

func (*MockManagerMockRecorder) RunChecks

func (mr *MockManagerMockRecorder) RunChecks(arg0, arg1 interface{}) *gomock.Call

RunChecks indicates an expected call of RunChecks.

func (*MockManagerMockRecorder) RunFixes

func (mr *MockManagerMockRecorder) RunFixes(arg0, arg1 interface{}) *gomock.Call

RunFixes indicates an expected call of RunFixes.

type Name

type Name string

Name is the name of an invariant

func NamePtr

func NamePtr(t Name) *Name

NamePtr returns a pointer to Name

type TimerInvalid added in v0.18.0

type TimerInvalid struct {
	// contains filtered or unexported fields
}

func (*TimerInvalid) Check added in v0.18.0

func (h *TimerInvalid) Check(
	ctx context.Context,
	e interface{},
) CheckResult

Check checks if timer is scheduled for open execution

func (*TimerInvalid) Fix added in v0.18.0

func (h *TimerInvalid) Fix(
	ctx context.Context,
	e interface{},
) FixResult

Fix will delete invalid timer

func (*TimerInvalid) Name added in v0.18.0

func (h *TimerInvalid) Name() Name

Jump to

Keyboard shortcuts

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