workflow

package
v1.1.124 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlowStatusPending     FlowStatus    = "pending"
	FlowStatusRunning     FlowStatus    = "running"
	FlowStatusDone        FlowStatus    = "done"
	FlowStatusFailed      FlowStatus    = "failed"
	TpConsistencyStrong   TpConsistency = "strong"
	TpConsistencyEventual TpConsistency = "eventual"
	EVENT_WORKFLOW_SET                  = "workflow:set"
	EVENT_WORKFLOW_DELETE               = "workflow:delete"
	EVENT_WORKFLOW_STATUS               = "workflow:status"
)
View Source
const (
	MSG_FLOW_CREATED              = "Flujo creado Tag:%s version:%s name:%s"
	MSG_START_WORKFLOW            = "Start the workflow"
	MSG_INSTANCE_FAILED           = "Instance fallido:%s Tag:%s status:%s, step:%d error:%s"
	MSG_INSTANCE_STATUS           = "Instance:%s Tag:%s status:%s, step:%d"
	MSG_INSTANCE_GOTO             = "Instance %s Tag:%s ir al step:%d, message:%s"
	MSG_INSTANCE_ALREADY_DONE     = "flow already done"
	MSG_INSTANCE_ALREADY_RUNNING  = "flow already running"
	MSG_INSTANCE_PENDING          = "flow is pending"
	MSG_INSTANCE_WORKFLOWS_IS_NIL = "workFlows is nil"
	MSG_ID_REQUIRED               = "id is required"
	MSG_INSTANCE_EXPRESSION_TRUE  = "Resultado de la expresion es true"
	MSG_INSTANCE_EXPRESSION_FALSE = "Resultado de la expresion es false"
	MSG_INSTANCE_ROLLBACK         = "Esta intentando hacer rollback de un step que no existe"
	MSG_INSTANCE_ROLLBACK_STEP    = "haciendo rollback del step:%d"
	MSG_INSTANCE_STEP_CREATED     = "Step creado:%d name:%s Tag:%s"
	MSG_INSTANCE_ROLLBACK_CREATED = "Rollback creado:%d name:%s Tag:%s"
	MSG_INSTANCE_ROLLBACK_FAILED  = "Rollback Instance:%s Tag:%s status:%s, step:%d error:%s"
	MSG_INSTANCE_CONSISTENCY      = "Consistencia definida Tag:%s consistency:%s"
	MSG_INSTANCE_RESILIENCE       = "Resilencia definida Tag:%s totalAttempts:%d timeAttempts:%s retentionTime:%s"
	MSG_INSTANCE_IFELSE           = "IfElse definido step:%d name:%s expresion:%s ? %d : %d Tag:%s"
)

Variables

This section is empty.

Functions

func DeleteFlow

func DeleteFlow(tag string) (bool, error)

* * DeleteFlow * @param tag string * @return (bool, error) *

func HealthCheck

func HealthCheck() bool

* * HealthCheck * @return bool *

func Load

func Load() error

* * Load * @return error

func Rollback

func Rollback(instanceId string) (et.Json, error)

* * Rollback * @param instanceId string * @return et.Json, error *

func Run

func Run(instanceId, tag string, startId int, ctx et.Json) (et.Json, error)

* * Run * @param instanceId, tag string, ctx et.Json * @return et.Json, error *

Types

type Flow

type Flow struct {
	Tag           string          `json:"tag"`
	Version       string          `json:"version"`
	Name          string          `json:"name"`
	Description   string          `json:"description"`
	Current       int             `json:"current"`
	TotalAttempts int             `json:"total_attempts"`
	TimeAttempts  time.Duration   `json:"time_attempts"`
	RetentionTime time.Duration   `json:"retention_time"`
	Ctx           et.Json         `json:"ctx"`
	Steps         []*Step         `json:"steps"`
	Ctxs          map[int]et.Json `json:"ctxs"`
	Results       map[int]Result  `json:"results"`
	Rollbacks     map[int]Result  `json:"rollbacks"`
	LastRollback  int             `json:"last_rollback"`
	TpConsistency TpConsistency   `json:"tp_consistency"`
	Id            string          `json:"id"`
	CreatedAt     time.Time       `json:"created_at"`
	UpdatedAt     time.Time       `json:"updated_at"`
	DoneAt        time.Time       `json:"done_at"`
	Status        FlowStatus      `json:"status"`
	CreatedBy     string          `json:"created_by"`
	WorkerHost    string          `json:"worker_host"`
	// contains filtered or unexported fields
}

func New

func New(tag, version, name, description string, fn FnContext, createdBy string) *Flow

* * New * @param tag, version, name, description string, fn FnContext, createdBy string * @return *Flow *

func (*Flow) Consistency

func (s *Flow) Consistency(consistency TpConsistency) *Flow

* * Consistency * @param consistency TpConsistency * @return *Flow *

func (*Flow) IfElse

func (s *Flow) IfElse(expression string, yesGoTo int, noGoTo int) *Flow

* * IfElse * @param expression string, yesGoTo int, noGoTo int * @return *Flow, error *

func (*Flow) Resilence

func (s *Flow) Resilence(totalAttempts int, timeAttempts, retentionTime time.Duration) *Flow

* * Resilence * @param totalAttempts int, timeAttempts, retentionTime time.Duration * @return *Flow *

func (*Flow) Rollback

func (s *Flow) Rollback(fn FnContext) *Flow

* * Rollback * @params fn FnContext * @return *Flow *

func (*Flow) Run

func (s *Flow) Run(instanceId string, startId int, ctx et.Json) (et.Json, error)

* * Run * @param instanceId string, startId int, ctx et.Json * @return et.Json, error *

func (*Flow) Step

func (s *Flow) Step(name, description string, fn FnContext, stop bool) *Flow

* * Step * @param name, description string, fn FnContext, retries, retryDelay int, stop bool * @return *Fn *

func (*Flow) ToJson

func (s *Flow) ToJson() et.Json

* * ToJson * @return et.Json *

type FlowStatus

type FlowStatus string

type FnContext

type FnContext func(flow *Flow, ctx et.Json) (et.Json, error)

type Result

type Result struct {
	Step    int     `json:"step"`
	Ctx     et.Json `json:"ctx"`
	Attempt int     `json:"attempt"`
	Result  et.Json `json:"result"`
	Error   string  `json:"error"`
}

type Step

type Step struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Stop        bool   `json:"stop"`
	Expression  string `json:"expression"`
	YesGoTo     int    `json:"yes_go_to"`
	NoGoTo      int    `json:"no_go_to"`
	// contains filtered or unexported fields
}

func (*Step) Evaluate

func (s *Step) Evaluate(ctx et.Json, instance *Flow) (bool, error)

* * Evaluate * @param ctx et.Json * @return bool, error *

func (*Step) IfElse

func (s *Step) IfElse(expression string, yesGoTo int, noGoTo int) *Step

* * If * @param expression string, yesGoTo int, noGoTo int * @return *Step, error *

func (*Step) ToJson

func (s *Step) ToJson() et.Json

* * ToJson * @return et.Json *

type TpConsistency

type TpConsistency string

type WorkFlows

type WorkFlows struct {
	Flows    map[string]*Flow `json:"flows"`
	Instance map[string]*Flow `json:"instance"`
}

func NewWorkFlows

func NewWorkFlows() *WorkFlows

* * NewWorkFlows * @return *WorkFlows *

func (*WorkFlows) DeleteFlow

func (s *WorkFlows) DeleteFlow(tag string) bool

* * DeleteFlow * @param tag string * @return bool *

func (*WorkFlows) HealthCheck

func (s *WorkFlows) HealthCheck() bool

* * HealthCheck * @return bool *

func (*WorkFlows) NewFlow

func (s *WorkFlows) NewFlow(tag, version, name, description string, fn FnContext, createdBy string) *Flow

* * NewFlow * @param tag, version, name, description string, fn FnContext, createdBy string * @return *Flow *

func (*WorkFlows) Rollback

func (s *WorkFlows) Rollback(instanceId string) (et.Json, error)

func (*WorkFlows) Run

func (s *WorkFlows) Run(instanceId, tag string, startId int, ctx et.Json) (et.Json, error)

* * Run * @param instanceId, tag string, ctx et.Json * @return et.Json, error *

Jump to

Keyboard shortcuts

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