Versions in this module Expand all Collapse all v0 v0.0.2 Dec 25, 2025 Changes in this version + var ErrWorkflowParamInvalid = errors.New("invalid param") v0.0.1 Dec 24, 2025 Changes in this version + const WorkflowTaskNodeStatusCancelled + const WorkflowTaskNodeStatusCompleted + const WorkflowTaskNodeStatusFailed + const WorkflowTaskNodeStatusFinishing + const WorkflowTaskNodeStatusInit + const WorkflowTaskNodeStatusPending + const WorkflowTaskNodeStatusRestarting + const WorkflowTaskNodeStatusRunning + const WorkflowTaskNodeStatusStatusUnCreated + var ErrWorkBussinessCriticalError = errors.New("work bussiness critical error") + var ErrWorkBussinessWarningError = errors.New("work bussiness warning error") + var ErrWorkflowConfigNotFound = errors.New("workflow config not found") + var ErrWorkflowDefinitionNotFound = errors.New("workflow definition not found") + var ErrWorkflowInstanceNotFound = errors.New("workflow instance not found") + var ErrWorkflowTaskFailedWithFailed = errors.New("workflow task failed with termination") + var ErrWorkflowTaskInstanceNotFound = errors.New("workflow task instance not found") + var ErrWorkflowTaskWorkerAlreadyRegistered = errors.New("workflow task worker already registered") + var ErrWorkflowTaskWorkerNotFound = errors.New("workflow task worker not found") + var ErrorWorkflowTaskFailedWithContinue = errors.New("workflow task failed with continue") + var ErrorWorkflowTaskInstanceNotReady = errors.New("workflow task instance not ready") + var LockFailedError = errors.New("lock failed") + var LockFailedTimeOutError = errors.New("wait time out") + func Bool(b bool) *bool + func BuildAddWorkfNode(endNode *WorkflowTaskNodeDefinition, addNode *WorkflowTaskNodeDefinition, ...) error + func GetWorkflowInstanceStatusText(status WorkflowInstanceStatus) string + func GetWorkflowTaskNodeStatusText(status WorkflowTaskNodeStatus) string + func IsOverWorkflowInstanceStatus(status WorkflowInstanceStatus) bool + func IsOverWorkflowTaskNodeStatus(status WorkflowTaskNodeStatus) bool + func IsSeriousError(err error) bool + func LoadWorkflowConfig(config *WorkflowConfig) error + func PreloadingWorkflowDefinition() error + func RegisterWorkflowTask(workflowType string, taskKey string, taskWorker WorkflowTaskNodeWorker) error + func String(s string) *string + func StructUnmarshal(ctx *JSONContext, v any) error + func UniqueStr(arr []string) []string + type AddNodeExternalEventParams struct + NodeEvent *NodeExternalEvent + TaskType string + WorkflowInstanceID int64 + type AsynchronousWaitCheckFunc func(ctx context.Context, nodeContext *JSONContext) error + type BaseTaskWorker struct + func (w BaseTaskWorker) AsynchronousWaitCheck(ctx context.Context, nodeContext *JSONContext) error + type CreateWorkflowReq struct + BusinessID string + Context map[string]any + IsRun bool + TaskId int64 + WorkflowType string + type EmptyTaskWorker struct + func (w EmptyTaskWorker) AsynchronousWaitCheck(ctx context.Context, nodeContext *JSONContext) error + func (w EmptyTaskWorker) Run(ctx context.Context, nodeContext *JSONContext) error + type EndNodeWorker struct + func (w EndNodeWorker) Run(ctx context.Context, nodeContext *JSONContext) error + type JSONContext struct + func MergeJSONContexts(contexts ...*JSONContext) *JSONContext + func NewByte2StrctPbValue(b []byte) *JSONContext + func NewJSONContext(b []byte) *JSONContext + func NewJSONContextFromMap(m map[string]any) *JSONContext + func (c *JSONContext) Clone() *JSONContext + func (c *JSONContext) Delete(keys ...string) + func (c *JSONContext) Get(keys ...string) (any, bool) + func (c *JSONContext) GetBool(keys ...string) (bool, bool) + func (c *JSONContext) GetFloat64(keys ...string) (float64, bool) + func (c *JSONContext) GetInt64(keys ...string) (int64, bool) + func (c *JSONContext) GetString(keys ...string) (string, bool) + func (c *JSONContext) Set(keys []string, value any) error + func (c *JSONContext) ToBytes() ([]byte, error) + func (c *JSONContext) ToBytesWithoutError() []byte + func (c *JSONContext) ToMap() map[string]any + func (c *JSONContext) ToRawMessage() (json.RawMessage, error) + func (c *JSONContext) Unmarshal(v any) error + type NodeContextKey = string + const NodeContextKeyNodeEvent + const NodeContextKeyPreNodeContext + const NodeContextKeyReason + const NodeContextKeySystem + const NodeContextKeyWorkflowContext + type NodeDefinitionConfig struct + FailMaxCount *int64 + ID string + MaxWaitTimeTs *int64 + Name string + NextNodes []string + type NodeExternalEvent struct + EventContent string + EventTs int64 + type NormalTaskWorker struct + func NewNormalTaskWorker(funcRun RunFunc, funcAsynchronousWaitCheck AsynchronousWaitCheckFunc) *NormalTaskWorker + func (w NormalTaskWorker) AsynchronousWaitCheck(ctx context.Context, nodeContext *JSONContext) error + func (w NormalTaskWorker) Run(ctx context.Context, nodeContext *JSONContext) error + type Pager struct + IsNoLimit *bool + Page int64 + Size int64 + type QueryWorkflowInstanceParams struct + BusinessID *string + IDGreaterThan *int64 + OrderbyIDAsc *bool + Page *Pager + StatusIn []string + TaskID *int64 + WorkflowInstanceID *int64 + WorkflowTypeIn []string + type QueryWorkflowTaskInstanceParams struct + IDGreaterThan *int64 + OrderbyIDAsc *bool + Page *Pager + StatusIn []string + TaskType *string + WorkflowInstanceID *int64 + WorkflowTaskInstanceID *int64 + type RegisterWorkflowTaskParams struct + IsPublic bool + TaskKey string + TaskWorker WorkflowTaskNodeWorker + WorkflowType string + type RestartWorkflowNodeParams struct + IsForcedRestartWorkflow bool + TaskType string + WorkflowInstanceID int64 + type RestartWorkflowParams struct + IsRun bool + WorkflowInstanceID int64 + type RootNodeWorker struct + func (w RootNodeWorker) Run(ctx context.Context, nodeContext *JSONContext) error + type RunFunc func(ctx context.Context, nodeContext *JSONContext) error + type TaskInstanceEntity struct + CreatedAt int64 + ID int64 + NextNodesKeys []string + NodeContext *JSONContext + PreNodesKeys []string + Status string + TaskName string + TaskType string + UpdatedAt int64 + WorkflowInstanceID int64 + type UpdateWorkflowInstanceField struct + Status *string + WorkflowContext *JSONContext + type UpdateWorkflowInstanceParams struct + Fields *UpdateWorkflowInstanceField + LimitMax int + Where *UpdateWorkflowInstanceWhere + type UpdateWorkflowInstanceWhere struct + IDIn []int64 + StatusIn []string + type UpdateWorkflowTaskInstanceField struct + FailCount *int64 + NodeContext *JSONContext + Status *string + type UpdateWorkflowTaskInstanceParams struct + Fields *UpdateWorkflowTaskInstanceField + LimitMax int + Where *UpdateWorkflowTaskInstanceWhere + type UpdateWorkflowTaskInstanceWhere struct + IDIn []int64 + type WorkflowConfig struct + ID string + Name string + Nodes []*NodeDefinitionConfig + type WorkflowDefinition struct + ID string + Name string + Nodes []*WorkflowTaskNodeDefinition + NodesCount int64 + RootNode *WorkflowTaskNodeDefinition + func GetAndLoadWorkflowDefinition(workflowType string) (*WorkflowDefinition, error) + type WorkflowInstance struct + BusinessID string + CreatedAt int64 + Definitions *WorkflowDefinition + ID int64 + Status string + TaskId int64 + UpdatedAt int64 + WorkflowContext *JSONContext + WorkflowType string + type WorkflowInstanceDetailEntity struct + BusinessID string + CreatedAt int64 + ID int64 + Status WorkflowInstanceStatus + TaskInstances []*TaskInstanceEntity + UpdatedAt int64 + WorkflowContext *JSONContext + WorkflowType string + type WorkflowInstancePo struct + BusinessID string + CreatedAt int64 + ID int64 + Status WorkflowInstanceStatus + TaskId int64 + UpdatedAt int64 + WorkflowContext []byte + WorkflowType string + func (WorkflowInstancePo) TableName() string + type WorkflowInstanceStatus = string + const WorkflowInstanceStatusCancelled + const WorkflowInstanceStatusCompleted + const WorkflowInstanceStatusFailed + const WorkflowInstanceStatusInit + const WorkflowInstanceStatusRunning + type WorkflowLock interface + NonBlockingSynchronized func(ctx context.Context, key string, maxLockTimeDuration time.Duration, ...) error + func NewLocalWorkflowLock() WorkflowLock + func NewRedisWorkflowLock(redisClient redis.Cmdable) WorkflowLock + type WorkflowRepo interface + CountWorkflowInstance func(ctx context.Context, param *QueryWorkflowInstanceParams) (int64, error) + CreateWorkflowInstance func(ctx context.Context, workflowInstance *WorkflowInstancePo) (*WorkflowInstancePo, error) + CreateWorkflowTaskInstance func(ctx context.Context, workflowTaskInstance *WorkflowTaskInstancePo) (*WorkflowTaskInstancePo, error) + QueryWorkflowInstance func(ctx context.Context, param *QueryWorkflowInstanceParams) ([]*WorkflowInstancePo, error) + QueryWorkflowTaskInstance func(ctx context.Context, param *QueryWorkflowTaskInstanceParams) ([]*WorkflowTaskInstancePo, error) + Transaction func(ctx context.Context, fn func(ctx context.Context) error) error + UpdateWorkflowInstance func(ctx context.Context, param *UpdateWorkflowInstanceParams) error + UpdateWorkflowTaskInstance func(ctx context.Context, param *UpdateWorkflowTaskInstanceParams) error + func NewWorkflowRepo(db *gorm.DB) WorkflowRepo + type WorkflowService interface + AddNodeExternalEvent func(ctx context.Context, addParams *AddNodeExternalEventParams) error + CancelWorkflowInstance func(ctx context.Context, workflowInstanceID int64) error + CountWorkflowInstance func(ctx context.Context, params *QueryWorkflowInstanceParams) (int64, error) + CreateWorkflow func(ctx context.Context, req *CreateWorkflowReq) (*WorkflowInstance, error) + QueryWorkflowInstanceDetail func(ctx context.Context, params *QueryWorkflowInstanceParams) ([]*WorkflowInstanceDetailEntity, error) + QueryWorkflowInstancePo func(ctx context.Context, params *QueryWorkflowInstanceParams) ([]*WorkflowInstancePo, error) + RestartWorkflowInstance func(ctx context.Context, restartWorkflowParams *RestartWorkflowParams) error + RestartWorkflowNode func(ctx context.Context, restartWorkflowNodeParams *RestartWorkflowNodeParams) error + RunWorkflow func(ctx context.Context, workflowID int64) error + func NewWorkflowService(repo WorkflowRepo, executeLock WorkflowLock) WorkflowService + type WorkflowServiceImpl struct + func (s *WorkflowServiceImpl) AddNodeExternalEvent(ctx context.Context, addParams *AddNodeExternalEventParams) error + func (s *WorkflowServiceImpl) CancelWorkflowInstance(ctx context.Context, workflowInstanceID int64) error + func (s *WorkflowServiceImpl) CountWorkflowInstance(ctx context.Context, params *QueryWorkflowInstanceParams) (int64, error) + func (s *WorkflowServiceImpl) CreateWorkflow(ctx context.Context, req *CreateWorkflowReq) (*WorkflowInstance, error) + func (s *WorkflowServiceImpl) QueryWorkflowInstanceDetail(ctx context.Context, params *QueryWorkflowInstanceParams) ([]*WorkflowInstanceDetailEntity, error) + func (s *WorkflowServiceImpl) QueryWorkflowInstancePo(ctx context.Context, params *QueryWorkflowInstanceParams) ([]*WorkflowInstancePo, error) + func (s *WorkflowServiceImpl) RestartWorkflowInstance(ctx context.Context, restartParams *RestartWorkflowParams) error + func (s *WorkflowServiceImpl) RestartWorkflowNode(ctx context.Context, restartParams *RestartWorkflowNodeParams) error + func (s *WorkflowServiceImpl) RunWorkflow(ctx context.Context, workflowID int64) error + type WorkflowTaskInstancePo struct + CreatedAt int64 + FailCount int64 + ID int64 + NodeContext []byte + Status WorkflowTaskNodeStatus + TaskType string + UpdatedAt int64 + WorkflowInstanceID int64 + func (WorkflowTaskInstancePo) TableName() string + type WorkflowTaskNode struct + CreatedAt int64 + FailCount int64 + ID int64 + NodeContext *JSONContext + Status string + TaskType string + UpdatedAt int64 + WorkflowInstanceID int64 + type WorkflowTaskNodeDefinition struct + FailMaxCount int64 + MaxWaitTimeTs int64 + NextNodes []*WorkflowTaskNodeDefinition + PreNodes []*WorkflowTaskNodeDefinition + TaskName string + TaskType string + TaskWorker WorkflowTaskNodeWorker + func NewEndTaskNodeDefinition() *WorkflowTaskNodeDefinition + func NewRootTaskNodeDefinition() *WorkflowTaskNodeDefinition + type WorkflowTaskNodeStatus = string + type WorkflowTaskNodeWorker interface + AsynchronousWaitCheck func(ctx context.Context, nodeContext *JSONContext) error + Run func(ctx context.Context, nodeContext *JSONContext) error