Documentation
¶
Index ¶
- type Config
- type MemorySharedSpace
- func (m *MemorySharedSpace) Clear() error
- func (m *MemorySharedSpace) ClearNotify() error
- func (m *MemorySharedSpace) Delete(key string) error
- func (m *MemorySharedSpace) Get(key string) (interface{}, error)
- func (m *MemorySharedSpace) Restore(data map[string]interface{}) error
- func (m *MemorySharedSpace) Set(key string, value interface{}) error
- func (m *MemorySharedSpace) Snapshot() map[string]interface{}
- func (m *MemorySharedSpace) Subscribe(key string, callback func(key string, value interface{})) error
- func (m *MemorySharedSpace) Unsubscribe(key string) error
- type Option
- type Plan
- func (p *Plan) AddTask(id string, order int, fn TaskFunc) error
- func (p *Plan) GetStatus() (Status, map[string]Status)
- func (p *Plan) GetTaskData(taskID string) (interface{}, error)
- func (p *Plan) GetTaskStatus(taskID string) (Status, error)
- func (p *Plan) Pause() error
- func (p *Plan) Release()
- func (p *Plan) RemoveTask(id string) error
- func (p *Plan) Resume() error
- func (p *Plan) Start() error
- func (p *Plan) Stop() error
- func (p *Plan) Trigger(event string, data interface{})
- type SharedSpace
- type Signal
- type Space
- type Status
- type Task
- type TaskFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// StatusCheckInterval is the interval between status checks
StatusCheckInterval time.Duration
}
Config represents plan configuration
type MemorySharedSpace ¶
type MemorySharedSpace struct {
// contains filtered or unexported fields
}
MemorySharedSpace implements SharedSpace interface using in-memory storage
func NewMemorySharedSpace ¶
func NewMemorySharedSpace() *MemorySharedSpace
NewMemorySharedSpace creates a new MemorySharedSpace instance
func (*MemorySharedSpace) Clear ¶
func (m *MemorySharedSpace) Clear() error
Clear removes all values from the shared space
func (*MemorySharedSpace) ClearNotify ¶
func (m *MemorySharedSpace) ClearNotify() error
ClearNotify removes all values from the shared space and notifies subscribers
func (*MemorySharedSpace) Delete ¶
func (m *MemorySharedSpace) Delete(key string) error
Delete removes a value from the shared space
func (*MemorySharedSpace) Get ¶
func (m *MemorySharedSpace) Get(key string) (interface{}, error)
Get retrieves a value from the shared space
func (*MemorySharedSpace) Restore ¶
func (m *MemorySharedSpace) Restore(data map[string]interface{}) error
Restore sets multiple key-value pairs from a snapshot Used for recovering space state after interruption
func (*MemorySharedSpace) Set ¶
func (m *MemorySharedSpace) Set(key string, value interface{}) error
Set stores a value in the shared space
func (*MemorySharedSpace) Snapshot ¶
func (m *MemorySharedSpace) Snapshot() map[string]interface{}
Snapshot returns a copy of all key-value pairs in the shared space Used for persisting space state for recovery purposes
func (*MemorySharedSpace) Subscribe ¶
func (m *MemorySharedSpace) Subscribe(key string, callback func(key string, value interface{})) error
Subscribe subscribes to changes in the shared space
func (*MemorySharedSpace) Unsubscribe ¶
func (m *MemorySharedSpace) Unsubscribe(key string) error
Unsubscribe removes a subscription
type Option ¶
type Option func(*Config)
Option represents a function that modifies the plan configuration
func WithStatusCheckInterval ¶
WithStatusCheckInterval sets the status check interval
type Plan ¶
type Plan struct {
ID string
Tasks map[string]*Task
Status Status
Context context.Context
Cancel context.CancelFunc
Config *Config
}
Plan represents a collection of tasks with shared space
func (*Plan) GetTaskData ¶
GetTaskData returns the data associated with a specific task
func (*Plan) GetTaskStatus ¶
GetTaskStatus returns the status of a specific task
func (*Plan) RemoveTask ¶
RemoveTask removes a task from the plan
type SharedSpace ¶
type SharedSpace interface {
Set(key string, value interface{}) error
Get(key string) (interface{}, error)
Delete(key string) error
Clear() error
ClearNotify() error
Subscribe(key string, callback func(key string, value interface{})) error
Unsubscribe(key string) error
}
SharedSpace represents the interface for shared storage space
type Space ¶
type Space interface {
Set(key string, value interface{}) error
Get(key string) (interface{}, error)
Delete(key string) error
Clear() error
ClearNotify() error
Subscribe(key string, callback func(key string, value interface{})) error
Unsubscribe(key string) error
Snapshot() map[string]interface{} // Returns a copy of all key-value pairs
Restore(data map[string]interface{}) error // Restores multiple key-value pairs from a snapshot
}
Space interface