ElGraph.Runner (ElGraph v0.3.0)

Copy Markdown View Source

호출 단위 실행의 프로세스 래퍼 (SPEC §3.4, §3.9).

  • start_run/3 — nolink + monitor. 실행 실패를 직접 다루려는 소유자(L3 에이전트)용.
  • await/2 — 실행 결과 수신.
  • cancel/2 — 협조적 취소(:atomics 플래그 → ElGraph.Ctx.cancelled?/1), 유예시간(:cancel_timeout, 기본 5초) 후 brutal kill.

스트리밍은 ElGraph.stream/3을 사용한다 (호출자 link — 고아 실행 방지).

Summary

Functions

실행 결과를 기다린다. 러너가 비정상 종료하면 {:error, :killed} 등을 반환한다.

실행을 취소한다. 취소 플래그를 세우고 러너 종료를 기다리며, :cancel_timeout(기본 5초) 안에 끝나지 않으면 brutal kill 한다.

Registry에 등록된 실행 중 thread 목록 (introspection, SPEC §3.4 / 부록 A-1).

실행 중인 thread의 현재 진행 상황: {:ok, %{pid:, step:, active:}} 또는 :not_found.

체크포인트 재개를 별도 프로세스(nolink + monitor)로 시작한다.

그래프 실행을 별도 프로세스(nolink + monitor)로 시작한다.

Functions

await(run, timeout \\ 5000)

@spec await(ElGraph.Runner.Run.t(), timeout()) ::
  ElGraph.Executor.result() | {:error, term()}

실행 결과를 기다린다. 러너가 비정상 종료하면 {:error, :killed} 등을 반환한다.

cancel(run, opts \\ [])

@spec cancel(
  ElGraph.Runner.Run.t(),
  keyword()
) :: :ok

실행을 취소한다. 취소 플래그를 세우고 러너 종료를 기다리며, :cancel_timeout(기본 5초) 안에 끝나지 않으면 brutal kill 한다.

list(registry)

@spec list(atom()) :: [
  %{
    thread_id: String.t(),
    pid: pid(),
    step: non_neg_integer(),
    active: [atom()]
  }
]

Registry에 등록된 실행 중 thread 목록 (introspection, SPEC §3.4 / 부록 A-1).

start_run/3:registry 옵션을 준 실행만 나타나며, 실행 프로세스가 죽으면 Registry가 자동 정리한다.

peek(registry, thread_id)

@spec peek(atom(), String.t()) ::
  {:ok, %{pid: pid(), step: non_neg_integer(), active: [atom()]}} | :not_found

실행 중인 thread의 현재 진행 상황: {:ok, %{pid:, step:, active:}} 또는 :not_found.

start_resume(graph, opts)

@spec start_resume(
  ElGraph.Graph.t(),
  keyword()
) :: {:ok, ElGraph.Runner.Run.t()}

체크포인트 재개를 별도 프로세스(nolink + monitor)로 시작한다.

ElGraph.resume/2의 비동기 버전 — 에이전트의 crash-only 복구(SPEC §5)에 쓰인다.

start_run(graph, input, opts \\ [])

@spec start_run(ElGraph.Graph.t(), map() | keyword(), keyword()) ::
  {:ok, ElGraph.Runner.Run.t()}

그래프 실행을 별도 프로세스(nolink + monitor)로 시작한다.