Interface FlowInstanceService

All Known Implementing Classes:
DefaultFlowInstanceService

public interface FlowInstanceService
Flow-instance facade: start, get, list, terminate. 流程实例门面:启动、查询、列表、终止。
Since:
JDK 25, opencode-base-flow V1.0.5
Author:
Leon Soo
  • Method Details

    • start

      FlowInstance start(String flowKey, String initiatorId, Map<String,Object> variables)
      Start a new instance for the given business key. 启动一个新实例。
      Parameters:
      flowKey - business key — 业务 key
      initiatorId - initiator user id — 发起人
      variables - business variables (nullable) — 业务变量(可空)
      Returns:
      persisted instance — 已持久化实例
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • get

      FlowInstance get(String instanceId)
      Returns the instance by id (or throws INST_NOT_FOUND). 按 id 返回实例(不存在抛 INST_NOT_FOUND)。
      Parameters:
      instanceId - instance id — 实例 ID
      Returns:
      instance — 实例
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • findByInitiator

      List<FlowInstance> findByInitiator(String userId, int page, int size)
      Paginated list of instances started by the given user. 分页查询某发起人启动的实例。
      Parameters:
      userId - initiator user id — 发起人
      page - zero-based page — 页码(0 起)
      size - page size — 每页大小
      Returns:
      instances on the requested page — 该页实例
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • terminate

      void terminate(String instanceId, String operatorId, String reason)
      Terminate the running instance (out-of-band). Cancels every PENDING task; writes a history record. 终止运行中的实例(外部操作)。取消所有 PENDING task;写一条 history。
      Parameters:
      instanceId - instance id — 实例 ID
      operatorId - operator user id — 操作人
      reason - reason (nullable) — 理由
      Since:
      JDK 25, opencode-base-flow V1.0.5