workflow

package
v1.1.196 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EVENT_WORKFLOW_SET      = "workflow:set"
	EVENT_WORKFLOW_DELETE   = "workflow:delete"
	EVENT_WORKFLOW_STATUS   = "workflow:status"
	EVENT_WORKFLOW_AWAITING = "workflow:awaiting"
	EVENT_WORKFLOW_RESULTS  = "workflow:results"
)
View Source
const (
	MSG_FLOW_CREATED                = "Flujo definido Tag:%s version:%s name:%s"
	MSG_FLOW_NOT_FOUND              = "Flujo no encontrado"
	MSG_FLOW_NOT_INSTANCE           = "Flujo no instanciado"
	MSG_START_WORKFLOW              = "Iniciando el workflow"
	MSG_INSTANCE_ID_REQUIRED        = "Instance id es requerido"
	MSG_INSTANCE_NOT_FOUND          = "Instancia no encontrada"
	MSG_INSTANCE_EXISTS             = "Instancia existe"
	MSG_INSTANCE_FAILED             = "Instancia fallido:%s Tag:%s status:%s, step:%d error:%s"
	MSG_INSTANCE_STATUS             = "Instancia:%s Tag:%s status:%s, step:%d"
	MSG_INSTANCE_DEBUG              = "Instancia:%s debug:%s"
	MSG_INSTANCE_GOTO               = "Instancia %s Tag:%s ir al step:%d %s"
	MSG_INSTANCE_LOAD               = "Instancia load:%s tag:%s currentStep:%d"
	MSG_INSTANCE_ALREADY_DONE       = "Instancia ya finalizada Id:%s"
	MSG_INSTANCE_ALREADY_RUNNING    = "Instancia ya en ejecucion Id:%s"
	MSG_INSTANCE_PENDING            = "Instancia pendiente Id:%s"
	MSG_INSTANCE_CANCEL             = "Instancia cancelada Id:%s"
	MSG_INSTANCE_LOSS               = "Instancia perdida Id:%s"
	MSG_INSTANCE_WORKFLOWS_IS_NIL   = "workFlows es nil"
	MSG_ID_REQUIRED                 = "id es requerido"
	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       = "Definido step:%d name:%s Tag:%s"
	MSG_INSTANCE_ROLLBACK_CREATED   = "Definido rollback step:%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         = "Definida resilencia Tag:%s totalAttempts:%d timeAttempts:%s retentionTime:%s"
	MSG_INSTANCE_IFELSE             = "Definido ifElse step:%d name:%s expresion:%s ? %d : %d Tag:%s"
	MSG_INSTANCE_RETENTION          = "Definida retencion Tag:%s retentionTime:%s"
	MSG_INSTANCE_GOTO_USER_DECISION = "Por desicion del usuario"
	MSG_WORKFLOW_DELETE             = "Workflow eliminado Tag:%s"
	MSG_WORKFLOW_DONE_INSTANCE      = "Instancia terminada:%s"
	MSG_WORKFLOW_LIMIT_REQUESTS     = "Límite de peticiones alcanzado, el proceso se pondra en espera para ejecusión, instanceId:%s"
	MSG_INSTANCE_RUN                = "Run instance:%s, flow:%s"
	MSG_INSTANCE_EVALUATE           = "error al evaluar expresion:%s, error:%s"
)

Variables

View Source
var (
	ErrorInstanceNotFound = fmt.Errorf(MSG_INSTANCE_NOT_FOUND)
)

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 Reset added in v1.1.133

func Reset(instanceId, updatedBy string) error

* * Reset * @param instanceId, updatedBy string * @return error *

func Rollback

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

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

func Run

func Run(instanceId, tag string, step int, tags et.Json, ctx et.Json, createdBy string) (et.Json, error)

* * Run * @param instanceId, tag string, step int, tags et.Json, ctx et.Json, createdBy string * @return et.Json, error *

func SetLoadInstance added in v1.1.161

func SetLoadInstance(fn LoadInstanceFn)

func SetSaveInstance added in v1.1.161

func SetSaveInstance(fn SaveInstanceFn)

func Stop added in v1.1.128

func Stop(instanceId, updatedBy string) error

* * Stop * @param instanceId, updatedBy string * @return error *

Types

type Flow

type Flow struct {
	Tag           string        `json:"tag"`
	Version       string        `json:"version"`
	Name          string        `json:"name"`
	Description   string        `json:"description"`
	TotalAttempts int           `json:"total_attempts"`
	TimeAttempts  time.Duration `json:"time_attempts"`
	RetentionTime time.Duration `json:"retention_time"`
	Steps         []*Step       `json:"steps"`
	TpConsistency TpConsistency `json:"tp_consistency"`
	Team          string        `json:"team"`
	Level         string        `json:"level"`
	CreatedBy     string        `json:"created_by"`
	// contains filtered or unexported fields
}

func New

func New(tag, version, name, description string, fn FnContext, stop bool, 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) Debug added in v1.1.127

func (s *Flow) Debug() *Flow

* * Debug * @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 time.Duration, team string, level string) *Flow

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

func (*Flow) Retention added in v1.1.127

func (s *Flow) Retention(retentionTime time.Duration) *Flow

* * Retention * @param retentionTime time.Duration * @return *Flow *

func (*Flow) Rollback

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

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

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
const (
	FlowStatusPending FlowStatus = "pending"
	FlowStatusRunning FlowStatus = "running"
	FlowStatusDone    FlowStatus = "done"
	FlowStatusFailed  FlowStatus = "failed"
	FlowStatusLoss    FlowStatus = "loss"
	FlowStatusCancel  FlowStatus = "cancel"
)

func Status added in v1.1.172

func Status(instanceId, status, updatedBy string) (FlowStatus, error)

* * Status * @param instanceId, status, updatedBy string * @return FlowStatus, error *

type FnContext

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

type Instance added in v1.1.128

type Instance struct {
	*Flow

	CreatedAt  time.Time       `json:"created_at"`
	UpdatedAt  time.Time       `json:"updated_at"`
	Tag        string          `json:"tag"`
	Id         string          `json:"id"`
	CreatedBy  string          `json:"created_by"`
	UpdatedBy  string          `json:"updated_by"`
	Current    int             `json:"current"`
	Ctx        et.Json         `json:"ctx"`
	Ctxs       map[int]et.Json `json:"ctxs"`
	Results    map[int]*Result `json:"results"`
	Rollbacks  map[int]*Result `json:"rollbacks"`
	Status     FlowStatus      `json:"status"`
	DoneAt     time.Time       `json:"done_at"`
	Tags       et.Json         `json:"tags"`
	WorkerHost string          `json:"worker_host"`
	Params     et.Json         `json:"params"`
	// contains filtered or unexported fields
}

func GetInstance added in v1.1.138

func GetInstance(instanceId string) (*Instance, error)

* * GetInstance * @param instanceId string * @return (*Instance, error) *

func (*Instance) Done added in v1.1.128

func (s *Instance) Done() error

* * Done * @return error *

func (*Instance) Goto added in v1.1.128

func (s *Instance) Goto(step int) error

* * Goto * @param step int * @return error *

func (*Instance) Save added in v1.1.163

func (s *Instance) Save() error

* * Save * @return error *

func (*Instance) Serialize added in v1.1.162

func (s *Instance) Serialize() ([]byte, error)

* * Serialize * @return ([]byte, error) *

func (*Instance) SetParam added in v1.1.142

func (s *Instance) SetParam(key string, value interface{})

* * SetParam * @param key string, value interface{} *

func (*Instance) SetStatus added in v1.1.156

func (s *Instance) SetStatus(status FlowStatus) error

* * SetStatus * @param status FlowStatus * @return error *

func (*Instance) Stop added in v1.1.128

func (s *Instance) Stop() error

* * Stop * @return error *

func (*Instance) ToJson added in v1.1.128

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

* * ToJson * @return et.Json *

type LoadInstanceFn added in v1.1.161

type LoadInstanceFn func(id string) (*Instance, 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"`
}

func (*Result) Serialize added in v1.1.128

func (s *Result) Serialize() (string, error)

* * Serialize * @return string *

func (*Result) ToJson added in v1.1.128

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

* * ToJson * @return et.Json *

type SaveInstanceFn added in v1.1.161

type SaveInstanceFn func(*Instance) 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) ToJson

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

* * ToJson * @return et.Json *

type TpConsistency

type TpConsistency string
const (
	TpConsistencyStrong   TpConsistency = "strong"
	TpConsistencyEventual TpConsistency = "eventual"
)

type WorkFlows

type WorkFlows struct {
	Flows     map[string]*Flow     `json:"flows"`
	Instances map[string]*Instance `json:"instances"`
	Results   map[string]et.Json   `json:"results"`
	// contains filtered or unexported fields
}

func (*WorkFlows) Add added in v1.1.173

func (s *WorkFlows) Add(instance *Instance)

* * Add * @param instance *Instance *

func (*WorkFlows) Count added in v1.1.173

func (s *WorkFlows) Count() int

* * Count * @return int *

func (*WorkFlows) Remove added in v1.1.173

func (s *WorkFlows) Remove(instance *Instance)

* * Remove * @param instance *Instance *

Jump to

Keyboard shortcuts

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