Documentation
¶
Index ¶
- Variables
- type Engine
- func (e *Engine) CleanupExpired(ctx context.Context) (int64, error)
- func (e *Engine) CleanupRun(ctx context.Context, namespace, runID string) error
- func (e *Engine) Delete(ctx context.Context, namespace, key string, runID *string) error
- func (e *Engine) Get(ctx context.Context, namespace, key string, opts *GetOpts) (*GetResult, error)
- func (e *Engine) History(ctx context.Context, namespace, key string, opts *HistoryOpts) (*HistoryResult, error)
- func (e *Engine) List(ctx context.Context, namespace string, opts *ListOpts) (*ListResult, error)
- func (e *Engine) Merge(ctx context.Context, namespace, key string, value any, opts *MergeOpts) (*MergeResult, error)
- func (e *Engine) Set(ctx context.Context, namespace, key string, value any, opts *SetOpts) (*SetResult, error)
- type GetOpts
- type GetResult
- type HistoryOpts
- type HistoryResult
- type ListOpts
- type ListResult
- type MergeOpts
- type MergeResult
- type SetOpts
- type SetResult
Constants ¶
This section is empty.
Variables ¶
var ( ErrKeyNotFound = errors.New("context key not found") ErrVersionConflict = errors.New("version conflict") ErrInvalidMerge = errors.New("cannot merge incompatible types") ErrEmptyKey = errors.New("context key cannot be empty") )
Common errors returned by the context engine.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine implements the workflow context logic layer. It orchestrates storage operations and provides merge functionality.
func (*Engine) CleanupExpired ¶
CleanupExpired removes all context entries past their TTL expiration.
func (*Engine) CleanupRun ¶
CleanupRun removes all context entries for a specific run.
func (*Engine) History ¶
func (e *Engine) History(ctx context.Context, namespace, key string, opts *HistoryOpts) (*HistoryResult, error)
History retrieves the version history for a key.
type GetOpts ¶
type GetOpts struct {
RunID *string // Optional: nil for persistent context
}
GetOpts contains options for retrieving context.
type GetResult ¶
type GetResult struct {
Key string `json:"key"`
Value any `json:"value"`
Version int64 `json:"version"`
UpdatedAt time.Time `json:"updated_at"`
Exists bool `json:"exists"`
}
GetResult contains the result of a context get operation.
type HistoryOpts ¶
type HistoryOpts struct {
RunID *string // Optional: nil for persistent context
Cursor string // Pagination cursor
Limit int // Max entries to return (0 = default)
}
HistoryOpts contains options for retrieving context history.
type HistoryResult ¶
type HistoryResult struct {
Key string `json:"key"`
History []*types.ContextHistoryEntry `json:"history"`
NextCursor string `json:"next_cursor,omitempty"`
}
HistoryResult contains the result of a context history operation.
type ListOpts ¶
type ListOpts struct {
RunID *string // Optional: nil for persistent context
Prefix *string // Optional key prefix filter
Cursor string // Pagination cursor
Limit int // Max keys to return (0 = default)
}
ListOpts contains options for listing context keys.
type ListResult ¶
type ListResult struct {
Keys []string `json:"keys"`
Count int `json:"count"`
NextCursor string `json:"next_cursor,omitempty"`
}
ListResult contains the result of a context list operation.
type MergeOpts ¶
type MergeOpts struct {
RunID *string // Optional: nil for persistent context
ExpectedVersion *int64 // For optimistic concurrency
Strategy types.MergeStrategy // Merge strategy (default: deep_merge)
ArrayStrategy types.ArrayStrategy // How to handle arrays in deep_merge
UpdatedBy string // Agent/task identifier
}
MergeOpts contains options for merging context.
type MergeResult ¶
type MergeResult struct {
Key string `json:"key"`
Version int64 `json:"version"`
MergedValue any `json:"merged_value"`
}
MergeResult contains the result of a context merge operation.