warden

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFinal = fmt.Errorf("will not be retried")
View Source
var ErrRetry = fmt.Errorf("will be retried")

Functions

func GetYoungestElement

func GetYoungestElement[T any](list []T, elementTimeProvider func(T) (time.Time, error)) (result T, err error)

Types

type Config

type Config struct {
	Interval          time.Duration
	AgeGate           time.Duration
	RunDbLoop         bool
	RunProcessLoop    bool
	RunDeploymentLoop bool
	Logger            *slog.Logger
}

type Controller

type Controller interface {
	StartDeploymentWithoutWardenHandling(networkId, processDeploymentId, businessKey string, startParameters map[string]interface{}) (err error, errCode int)
	StopProcessInstanceWithoutWardenHandling(instance model.ProcessInstance) (err error, errCode int)
	DeployProcessWithoutWardenHandling(networkId string, deployment model.DeploymentWithEventDesc) (err error)
}

type DbInterface

type DbInterface[WardenInfo WardenInfoInterface, DeploymentWardenInfo any, ProcessInstance any] interface {
	ListWardenInfo() iter.Seq2[WardenInfo, error]
	GetWardenInfoForInstance(ProcessInstance) ([]WardenInfo, error)
	GetWardenInfoForDeploymentId(deploymentId string) ([]WardenInfo, error)
	GetDeploymentWardenInfo(WardenInfo) (result DeploymentWardenInfo, exist bool, err error)
	SetWardenInfo(WardenInfo) error
	RemoveWardenInfo(WardenInfo) error
	SetDeploymentWardenInfo(info DeploymentWardenInfo) error
	RemoveDeploymentWardenById(networkId string, deploymentId string) error
	RemoveWardenInfoByBusinessKey(networkId string, businessKey string) error
	ListDeploymentWardenInfo() iter.Seq2[DeploymentWardenInfo, error]
	UpdateWardenInfoDeploymentId(networkId string, oldDeploymentId string, newDeploymentId string) error
}

type DeploymentWardenInfo

type DeploymentWardenInfo = model.DeploymentWardenInfo

type GenericWarden

type GenericWarden[WardenInfo WardenInfoInterface, DeploymentWardenInfo any, ProcessInstance any, History any, Incident any] struct {
	// contains filtered or unexported fields
}

func NewGeneric

func NewGeneric[WardenInfo WardenInfoInterface, DeploymentWardenInfo any, ProcessInstance any, History any, Incident any](config Config, processes ProcessesInterface[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident], db DbInterface[WardenInfo, DeploymentWardenInfo, ProcessInstance]) *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) AddDeploymentWarden

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) AddDeploymentWarden(info DeploymentWardenInfo) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) AddInstanceWarden

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) AddInstanceWarden(info WardenInfo) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) CheckDeploymentWardenInfo

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) CheckDeploymentWardenInfo(info DeploymentWardenInfo) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) CheckProcessInstance

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) CheckProcessInstance(instance ProcessInstance) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) CheckWardenInfo

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) CheckWardenInfo(info WardenInfo) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) InstanceIsCreatedWithWardenHandlingIntended

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) InstanceIsCreatedWithWardenHandlingIntended(instance ProcessInstance) bool

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) LoopDeploymentWardenDb

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) LoopDeploymentWardenDb() error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) LoopProcesses

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) LoopProcesses() error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) LoopWardenDb

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) LoopWardenDb() error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) MarkInstanceBusinessKeyAsWardenHandled

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) MarkInstanceBusinessKeyAsWardenHandled(businessKey string) string

MarkInstanceAsWardenHandled is intended to be used before the instance is handled by other services

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) RemoveDeployment

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) RemoveDeployment(deploymentId string) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) RemoveDeploymentWardenById

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) RemoveDeploymentWardenById(networkId string, deploymentId string) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) RemoveInstanceWarden

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) RemoveInstanceWarden(info WardenInfo) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) RemoveInstanceWardenByBusinessKey

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) RemoveInstanceWardenByBusinessKey(networkId string, businessKey string) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) RemoveWardenInfoByInstance

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) RemoveWardenInfoByInstance(instance ProcessInstance) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) Start

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) Start(ctx context.Context) error

func (*GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) UpdateWardenInfoDeploymentId

func (this *GenericWarden[WardenInfo, DeploymentWardenInfo, ProcessInstance, History, Incident]) UpdateWardenInfoDeploymentId(networkId string, oldDeploymentId string, newDeploymentId string) error

type Processes

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

func (*Processes) AllInstances

func (this *Processes) AllInstances() iter.Seq2[model.ProcessInstance, error]

func (*Processes) DeploymentExistsForDeploymentWarden

func (this *Processes) DeploymentExistsForDeploymentWarden(info DeploymentWardenInfo) (exist bool, err error)

func (*Processes) DeploymentExistsForWarden

func (this *Processes) DeploymentExistsForWarden(info WardenInfo) (exist bool, err error)

func (*Processes) GetIncidents

func (this *Processes) GetIncidents(history model.HistoricProcessInstance) ([]model.Incident, error)

func (*Processes) GetInstanceHistories

func (this *Processes) GetInstanceHistories(info WardenInfo) ([]model.HistoricProcessInstance, error)

func (*Processes) GetInstances

func (this *Processes) GetInstances(info WardenInfo) ([]model.ProcessInstance, error)

func (*Processes) GetYoungestHistory

func (this *Processes) GetYoungestHistory(histories []model.HistoricProcessInstance) (model.HistoricProcessInstance, error)

func (*Processes) GetYoungestIncident

func (this *Processes) GetYoungestIncident(incidents []model.Incident) (model.Incident, error)

func (*Processes) GetYoungestProcessInstance

func (this *Processes) GetYoungestProcessInstance(instances []model.ProcessInstance) (model.ProcessInstance, error)

func (*Processes) HistoryIsOlderThen

func (this *Processes) HistoryIsOlderThen(history model.HistoricProcessInstance, duration time.Duration) (bool, error)

func (*Processes) IncidentIsOlderThen

func (this *Processes) IncidentIsOlderThen(incident model.Incident, duration time.Duration) bool

func (*Processes) InstanceIsCreatedWithWardenHandlingIntended

func (this *Processes) InstanceIsCreatedWithWardenHandlingIntended(instance model.ProcessInstance) bool

func (*Processes) InstanceIsOldPlaceholder

func (this *Processes) InstanceIsOldPlaceholder(instance model.ProcessInstance) (bool, error)

func (*Processes) InstanceIsOlderThen

func (this *Processes) InstanceIsOlderThen(instance model.ProcessInstance, duration time.Duration) (bool, error)

func (*Processes) MarkInstanceBusinessKeyAsWardenHandled

func (this *Processes) MarkInstanceBusinessKeyAsWardenHandled(businessKey string) string

func (*Processes) Redeploy

func (this *Processes) Redeploy(info DeploymentWardenInfo) error

func (*Processes) Start

func (this *Processes) Start(info WardenInfo) (err error)

func (*Processes) Stop

func (this *Processes) Stop(instance model.ProcessInstance) (err error)

type ProcessesInterface

type ProcessesInterface[WardenInfo WardenInfoInterface, DeploymentWardenInfo, ProcessInstance any, History any, Incident any] interface {
	AllInstances() iter.Seq2[ProcessInstance, error]
	GetInstances(WardenInfo) ([]ProcessInstance, error)
	GetYoungestProcessInstance(instances []ProcessInstance) (ProcessInstance, error)
	InstanceIsOlderThen(ProcessInstance, time.Duration) (bool, error)
	InstanceIsCreatedWithWardenHandlingIntended(instance ProcessInstance) bool
	InstanceIsOldPlaceholder(instance ProcessInstance) (bool, error)

	MarkInstanceBusinessKeyAsWardenHandled(businessKey string) string

	GetInstanceHistories(WardenInfo) ([]History, error)
	GetYoungestHistory([]History) (History, error) //by start time?
	HistoryIsOlderThen(History, time.Duration) (bool, error)

	GetIncidents(History) ([]Incident, error)
	GetYoungestIncident([]Incident) (Incident, error)
	IncidentIsOlderThen(Incident, time.Duration) bool

	Start(WardenInfo) error
	Stop(ProcessInstance) error

	DeploymentExistsForWarden(WardenInfo) (exist bool, err error)
	DeploymentExistsForDeploymentWarden(DeploymentWardenInfo) (exist bool, err error)
	Redeploy(DeploymentWardenInfo) error
}

type WardenDb

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

func (*WardenDb) GetDeploymentWardenInfo

func (this *WardenDb) GetDeploymentWardenInfo(info WardenInfo) (result DeploymentWardenInfo, exists bool, err error)

func (*WardenDb) GetWardenInfoForDeploymentId

func (this *WardenDb) GetWardenInfoForDeploymentId(deploymentId string) ([]WardenInfo, error)

func (*WardenDb) GetWardenInfoForInstance

func (this *WardenDb) GetWardenInfoForInstance(instance model.ProcessInstance) ([]WardenInfo, error)

func (*WardenDb) ListDeploymentWardenInfo

func (this *WardenDb) ListDeploymentWardenInfo() iter.Seq2[DeploymentWardenInfo, error]

func (*WardenDb) ListWardenInfo

func (this *WardenDb) ListWardenInfo() iter.Seq2[WardenInfo, error]

func (*WardenDb) RemoveDeploymentWardenById

func (this *WardenDb) RemoveDeploymentWardenById(networkId string, deploymentId string) error

func (*WardenDb) RemoveWardenInfo

func (this *WardenDb) RemoveWardenInfo(info WardenInfo) error

func (*WardenDb) RemoveWardenInfoByBusinessKey

func (this *WardenDb) RemoveWardenInfoByBusinessKey(networkId string, businessKey string) error

func (*WardenDb) SetDeploymentWardenInfo

func (this *WardenDb) SetDeploymentWardenInfo(info model.DeploymentWardenInfo) error

func (*WardenDb) SetWardenInfo

func (this *WardenDb) SetWardenInfo(info WardenInfo) error

func (*WardenDb) UpdateWardenInfoDeploymentId

func (this *WardenDb) UpdateWardenInfoDeploymentId(networkId string, oldDeploymentId string, newDeploymentId string) error

type WardenInfo

type WardenInfo = model.WardenInfo

type WardenInfoInterface

type WardenInfoInterface interface {
	IsOlderThen(time.Duration) bool
	Validate() error
}

Jump to

Keyboard shortcuts

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