Documentation
¶
Overview ¶
Package checkpoint provides checkpoint storage and management for workflow runs, enabling restartability and time-travel resume. It includes an in-memory manager and a filesystem-backed JSON store.
Index ¶
- type FileSystemJSONStore
- func (s *FileSystemJSONStore) Close() error
- func (s *FileSystemJSONStore) CreateCheckpoint(_ context.Context, sessionID string, data json.RawMessage, ...) (workflow.CheckpointInfo, error)
- func (s *FileSystemJSONStore) RetrieveCheckpoint(_ context.Context, sessionID string, info workflow.CheckpointInfo) (json.RawMessage, error)
- func (s *FileSystemJSONStore) RetrieveIndex(_ context.Context, sessionID string, withParent *workflow.CheckpointInfo) ([]workflow.CheckpointInfo, error)
- type Manager
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileSystemJSONStore ¶
type FileSystemJSONStore struct {
// contains filtered or unexported fields
}
FileSystemJSONStore provides a file system-based implementation of a JSON Store, that persists checkpoint data and index information to disk using JSON files.
The store writes checkpoint files to a specified directory and maintains an index file for retrieval. It is intended for durable, process-exclusive checkpoint persistence. Instances are not safe for concurrent use by multiple goroutines without external synchronization. Call FileSystemJSONStore.Close when the store is no longer needed to release file handles and the process lock.
func NewFileSystemJSONStore ¶
func NewFileSystemJSONStore(rootDir string) (*FileSystemJSONStore, error)
NewFileSystemJSONStore creates a FileSystemJSONStore that uses rootDir for checkpoint storage. The directory is created if it does not exist.
An error is returned if rootDir cannot be created or resolved, if the store is already in use by another process, or if the existing index is corrupted.
func (*FileSystemJSONStore) Close ¶
func (s *FileSystemJSONStore) Close() error
Close releases the store's index file handle and process-exclusive lock.
func (*FileSystemJSONStore) CreateCheckpoint ¶
func (s *FileSystemJSONStore) CreateCheckpoint(_ context.Context, sessionID string, data json.RawMessage, parent *workflow.CheckpointInfo) (workflow.CheckpointInfo, error)
CreateCheckpoint implements Store.
func (*FileSystemJSONStore) RetrieveCheckpoint ¶
func (s *FileSystemJSONStore) RetrieveCheckpoint(_ context.Context, sessionID string, info workflow.CheckpointInfo) (json.RawMessage, error)
RetrieveCheckpoint implements Store.
func (*FileSystemJSONStore) RetrieveIndex ¶
func (s *FileSystemJSONStore) RetrieveIndex(_ context.Context, sessionID string, withParent *workflow.CheckpointInfo) ([]workflow.CheckpointInfo, error)
RetrieveIndex implements Store.
type Manager ¶
type Manager interface {
// LatestCheckpoint returns the most recently committed checkpoint for
// sessionID, or nil when the session has no checkpoints.
LatestCheckpoint(ctx context.Context, sessionID string) (*workflow.CheckpointInfo, error)
// contains filtered or unexported methods
}
A Manager for storing and retrieving workflow execution checkpoints.
func NewInMemoryManager ¶
func NewInMemoryManager() Manager
NewInMemoryManager creates a new instance of the Manager that uses in-memory storage for checkpoint data.
func NewJSONManager ¶
func NewJSONManager(store Store[json.RawMessage]) Manager
NewJSONManager creates a new instance of the Manager that uses JSON serialization for checkpoint data.
type Store ¶
type Store[T any] interface { // CreateCheckpoint persists a checkpoint and returns its identifying info. // parent is the info of the preceding checkpoint, if any. CreateCheckpoint(ctx context.Context, sessionID string, data T, parent *workflow.CheckpointInfo) (workflow.CheckpointInfo, error) // RetrieveCheckpoint loads previously saved checkpoint data. RetrieveCheckpoint(ctx context.Context, sessionID string, info workflow.CheckpointInfo) (T, error) // RetrieveIndex returns the ordered index of checkpoint identifiers for a // session. If withParent is non-nil only checkpoints whose parent matches // are returned. RetrieveIndex(ctx context.Context, sessionID string, withParent *workflow.CheckpointInfo) ([]workflow.CheckpointInfo, error) }
Store defines the interface for persisting and retrieving workflow checkpoint data. Implementations receive checkpoint data as values of type T and are responsible only for durable storage.
The framework serialises internal checkpoint state before calling the store, so store implementations never need to understand the checkpoint structure.