ElGraph.Checkpointer behaviour (ElGraph v0.3.0)

Copy Markdown View Source

체크포인트 영속화 behaviour (SPEC §3.5).

config는 어댑터별 핸들(ETS 테이블 참조, DB 풀 설정 등)이며 실행기는 내용을 모른다. 어댑터 적합성은 ElGraph.CheckpointerContract 공유 테스트로 검증한다.

Summary

Callbacks

체크포인트를 조회한다. :latest는 해당 thread의 최고 step.

보존된 pending writes를 조회한다. 없으면 [].

thread의 체크포인트 메타데이터를 step 오름차순으로 반환한다.

체크포인트를 저장한다. 같은 (thread_id, step)은 덮어쓴다.

superstep 내 완료된 노드들의 쓰기를 보존한다 (부분 실패 재개용 pending writes).

Types

config()

@type config() :: term()

node_write()

@type node_write() :: {atom(), map()}

step()

@type step() :: non_neg_integer()

thread_id()

@type thread_id() :: String.t()

Callbacks

get(config, thread_id, arg3)

@callback get(config(), thread_id(), :latest | step()) ::
  {:ok, ElGraph.Checkpoint.t()} | :not_found

체크포인트를 조회한다. :latest는 해당 thread의 최고 step.

get_writes(config, thread_id, step)

@callback get_writes(config(), thread_id(), step()) :: [node_write()]

보존된 pending writes를 조회한다. 없으면 [].

list(config, thread_id)

@callback list(config(), thread_id()) :: [%{step: step(), version: pos_integer()}]

thread의 체크포인트 메타데이터를 step 오름차순으로 반환한다.

put(config, t)

@callback put(config(), ElGraph.Checkpoint.t()) :: :ok | {:error, term()}

체크포인트를 저장한다. 같은 (thread_id, step)은 덮어쓴다.

put_writes(config, thread_id, step, list)

@callback put_writes(config(), thread_id(), step(), [node_write()]) ::
  :ok | {:error, term()}

superstep 내 완료된 노드들의 쓰기를 보존한다 (부분 실패 재개용 pending writes).