Documentation
¶
Overview ¶
Package store provides task persistence and retrieval.
Index ¶
- type FileStore
- func (fs *FileStore) ClaimForDispatch(id, owner string, expires time.Time) (bool, error)
- func (fs *FileStore) Close() error
- func (fs *FileStore) Delete(id string) error
- func (fs *FileStore) ForceSave() error
- func (fs *FileStore) Get(id string) (*models.Task, error)
- func (fs *FileStore) List(filter ListFilter) ([]*models.Task, error)
- func (fs *FileStore) ListByParentSession(sessionID string) ([]*models.Task, error)
- func (fs *FileStore) ReleaseClaim(id string) error
- func (fs *FileStore) Reload() error
- func (fs *FileStore) Save(task *models.Task) error
- func (fs *FileStore) UpdateStatus(id string, status models.TaskStatus) error
- type ListFilter
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore implements Store using a JSON file for persistence.
func NewFileStore ¶
NewFileStore creates a new file-based store.
func (*FileStore) ClaimForDispatch ¶ added in v0.629.4
ClaimForDispatch atomically reserves a pending task for owner. The claim is won only when the task exists, is still pending, and is not already held by a live (unexpired) lease — an expired lease is stolen, which is how a task stranded by a dispatcher crash becomes dispatchable again. The whole check and write happen under the store lock so two concurrent dispatchers can never both win.
func (*FileStore) Close ¶
Close stops the background saver and performs final save. Safe to call multiple times.
func (*FileStore) List ¶
func (fs *FileStore) List(filter ListFilter) ([]*models.Task, error)
List retrieves tasks matching the filter.
func (*FileStore) ListByParentSession ¶ added in v0.601.2
ListByParentSession returns all tasks whose ParentSessionID matches the given session id, newest first. It is a thin convenience wrapper over List.
func (*FileStore) ReleaseClaim ¶ added in v0.629.4
ReleaseClaim drops a task's dispatch claim. A missing task is not an error: releasing is cleanup, and cleanup must not fail because the thing being cleaned up is already gone.
func (*FileStore) UpdateStatus ¶
func (fs *FileStore) UpdateStatus(id string, status models.TaskStatus) error
UpdateStatus updates only the status of a task.
type ListFilter ¶
type ListFilter struct {
Status []models.TaskStatus
Tags []string
Limit int
Offset int
// ParentSessionID, when non-empty, restricts results to tasks whose
// ParentSessionID matches exactly. Used for delegation correlation queries.
ParentSessionID string
}
ListFilter defines criteria for listing tasks.
type Store ¶
type Store interface {
Save(task *models.Task) error
Get(id string) (*models.Task, error)
List(filter ListFilter) ([]*models.Task, error)
// ListByParentSession returns tasks correlated to the given parent agent
// session id (see Task.ParentSessionID). Used by delegation phases to find
// the tasks spawned by a session; no consumer reads it yet.
ListByParentSession(sessionID string) ([]*models.Task, error)
Delete(id string) error
UpdateStatus(id string, status models.TaskStatus) error
// ClaimForDispatch atomically reserves a pending task for execution by owner
// and returns whether the claim was won. It is the compare-and-set that makes
// dispatch safe when several readiness evaluations race for the same task
// (two dependencies completing at once used to start it twice).
ClaimForDispatch(id, owner string, expires time.Time) (bool, error)
// ReleaseClaim drops a task's dispatch claim. Safe to call on a task that
// holds none.
ReleaseClaim(id string) error
Close() error
}
Store defines the interface for task storage.