state

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package state provides BadgerDB-based state management

Package state provides memory-based state management

Package state provides interfaces for managing orchestrator state

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerStore

type BadgerStore struct {
	// contains filtered or unexported fields
}

BadgerStore implements Store interface using BadgerDB

func NewBadgerStore

func NewBadgerStore(config BadgerStoreConfig) (*BadgerStore, error)

NewBadgerStore creates a new BadgerDB-based store

func (*BadgerStore) Close

func (s *BadgerStore) Close(ctx context.Context) error

Close closes the store

func (*BadgerStore) CreateAgent

func (s *BadgerStore) CreateAgent(ctx context.Context, agent *types.Agent) error

CreateAgent creates a new agent

func (*BadgerStore) CreateWorkflow

func (s *BadgerStore) CreateWorkflow(ctx context.Context, workflow *types.Workflow) error

CreateWorkflow creates a new workflow

func (*BadgerStore) DeleteAgent

func (s *BadgerStore) DeleteAgent(ctx context.Context, agentID string) error

DeleteAgent removes an agent

func (*BadgerStore) DeleteWorkflow

func (s *BadgerStore) DeleteWorkflow(ctx context.Context, workflowID string) error

DeleteWorkflow removes a workflow

func (*BadgerStore) GetAgent

func (s *BadgerStore) GetAgent(ctx context.Context, agentID string) (*types.Agent, error)

GetAgent retrieves an agent by ID

func (*BadgerStore) GetEvents

func (s *BadgerStore) GetEvents(ctx context.Context, filter map[string]string, limit int) ([]*types.Event, error)

GetEvents retrieves events matching the filter

func (*BadgerStore) GetTask

func (s *BadgerStore) GetTask(ctx context.Context, workflowID, taskID string) (*types.Task, error)

GetTask retrieves a task from a workflow

func (*BadgerStore) GetWorkflow

func (s *BadgerStore) GetWorkflow(ctx context.Context, workflowID string) (*types.Workflow, error)

GetWorkflow retrieves a workflow by ID

func (*BadgerStore) HealthCheck

func (s *BadgerStore) HealthCheck(ctx context.Context) error

HealthCheck performs a health check

func (*BadgerStore) Initialize

func (s *BadgerStore) Initialize(ctx context.Context) error

Initialize initializes the store

func (*BadgerStore) ListAgents

func (s *BadgerStore) ListAgents(ctx context.Context, filter map[string]string) ([]*types.Agent, error)

ListAgents returns agents matching the filter

func (*BadgerStore) ListWorkflows

func (s *BadgerStore) ListWorkflows(ctx context.Context, filter map[string]string) ([]*types.Workflow, error)

ListWorkflows returns workflows matching the filter

func (*BadgerStore) RecordEvent

func (s *BadgerStore) RecordEvent(ctx context.Context, event *types.Event) error

RecordEvent records a system event

func (*BadgerStore) Transaction

func (s *BadgerStore) Transaction(ctx context.Context, fn func(tx StateManager) error) error

Transaction executes a function within a transaction

func (*BadgerStore) UpdateAgent

func (s *BadgerStore) UpdateAgent(ctx context.Context, agent *types.Agent) error

UpdateAgent updates an existing agent

func (*BadgerStore) UpdateTask

func (s *BadgerStore) UpdateTask(ctx context.Context, workflowID string, task *types.Task) error

UpdateTask updates a task within a workflow

func (*BadgerStore) UpdateWorkflow

func (s *BadgerStore) UpdateWorkflow(ctx context.Context, workflow *types.Workflow) error

UpdateWorkflow updates an existing workflow

type BadgerStoreConfig

type BadgerStoreConfig struct {
	Path     string
	EventTTL time.Duration
	Options  badger.Options
}

BadgerStoreConfig holds BadgerDB-specific configuration

type BadgerStoreFactory

type BadgerStoreFactory struct{}

BadgerStoreFactory creates BadgerDB store instances

func (*BadgerStoreFactory) Create

func (f *BadgerStoreFactory) Create(config Config) (Store, error)

Create creates a new BadgerDB store instance

type Config

type Config struct {
	Type    string // "memory", "badger", "postgres", etc.
	URL     string // Connection URL for external stores
	Path    string // File path for embedded stores
	Options map[string]interface{}
}

Config holds state store configuration

type Factory

type Factory interface {
	Create(config Config) (Store, error)
}

Factory creates state store instances

type MemoryStore

type MemoryStore struct {
	// contains filtered or unexported fields
}

MemoryStore implements Store interface using in-memory storage

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore creates a new memory-based store

func (*MemoryStore) Close

func (s *MemoryStore) Close(ctx context.Context) error

Close closes the store

func (*MemoryStore) CreateAgent

func (s *MemoryStore) CreateAgent(ctx context.Context, agent *types.Agent) error

CreateAgent creates a new agent

func (*MemoryStore) CreateWorkflow

func (s *MemoryStore) CreateWorkflow(ctx context.Context, workflow *types.Workflow) error

CreateWorkflow creates a new workflow

func (*MemoryStore) DeleteAgent

func (s *MemoryStore) DeleteAgent(ctx context.Context, agentID string) error

DeleteAgent removes an agent

func (*MemoryStore) DeleteWorkflow

func (s *MemoryStore) DeleteWorkflow(ctx context.Context, workflowID string) error

DeleteWorkflow removes a workflow

func (*MemoryStore) GetAgent

func (s *MemoryStore) GetAgent(ctx context.Context, agentID string) (*types.Agent, error)

GetAgent retrieves an agent by ID

func (*MemoryStore) GetEvents

func (s *MemoryStore) GetEvents(ctx context.Context, filter map[string]string, limit int) ([]*types.Event, error)

GetEvents retrieves events matching the filter

func (*MemoryStore) GetTask

func (s *MemoryStore) GetTask(ctx context.Context, workflowID, taskID string) (*types.Task, error)

GetTask retrieves a task from a workflow

func (*MemoryStore) GetWorkflow

func (s *MemoryStore) GetWorkflow(ctx context.Context, workflowID string) (*types.Workflow, error)

GetWorkflow retrieves a workflow by ID

func (*MemoryStore) HealthCheck

func (s *MemoryStore) HealthCheck(ctx context.Context) error

HealthCheck performs a health check

func (*MemoryStore) Initialize

func (s *MemoryStore) Initialize(ctx context.Context) error

Initialize initializes the store

func (*MemoryStore) ListAgents

func (s *MemoryStore) ListAgents(ctx context.Context, filter map[string]string) ([]*types.Agent, error)

ListAgents returns agents matching the filter

func (*MemoryStore) ListWorkflows

func (s *MemoryStore) ListWorkflows(ctx context.Context, filter map[string]string) ([]*types.Workflow, error)

ListWorkflows returns workflows matching the filter

func (*MemoryStore) RecordEvent

func (s *MemoryStore) RecordEvent(ctx context.Context, event *types.Event) error

RecordEvent records a system event

func (*MemoryStore) Transaction

func (s *MemoryStore) Transaction(ctx context.Context, fn func(tx StateManager) error) error

Transaction executes a function within a transaction

func (*MemoryStore) UpdateAgent

func (s *MemoryStore) UpdateAgent(ctx context.Context, agent *types.Agent) error

UpdateAgent updates an existing agent

func (*MemoryStore) UpdateTask

func (s *MemoryStore) UpdateTask(ctx context.Context, workflowID string, task *types.Task) error

UpdateTask updates a task within a workflow

func (*MemoryStore) UpdateWorkflow

func (s *MemoryStore) UpdateWorkflow(ctx context.Context, workflow *types.Workflow) error

UpdateWorkflow updates an existing workflow

type MemoryStoreFactory

type MemoryStoreFactory struct{}

MemoryStoreFactory creates memory store instances

func (*MemoryStoreFactory) Create

func (f *MemoryStoreFactory) Create(config Config) (Store, error)

Create creates a new memory store instance

type StateManager

type StateManager interface {
	// Agent state management
	CreateAgent(ctx context.Context, agent *types.Agent) error
	GetAgent(ctx context.Context, agentID string) (*types.Agent, error)
	UpdateAgent(ctx context.Context, agent *types.Agent) error
	DeleteAgent(ctx context.Context, agentID string) error
	ListAgents(ctx context.Context, filter map[string]string) ([]*types.Agent, error)

	// Workflow state management
	CreateWorkflow(ctx context.Context, workflow *types.Workflow) error
	GetWorkflow(ctx context.Context, workflowID string) (*types.Workflow, error)
	UpdateWorkflow(ctx context.Context, workflow *types.Workflow) error
	DeleteWorkflow(ctx context.Context, workflowID string) error
	ListWorkflows(ctx context.Context, filter map[string]string) ([]*types.Workflow, error)

	// Task state management
	GetTask(ctx context.Context, workflowID, taskID string) (*types.Task, error)
	UpdateTask(ctx context.Context, workflowID string, task *types.Task) error

	// Event management
	RecordEvent(ctx context.Context, event *types.Event) error
	GetEvents(ctx context.Context, filter map[string]string, limit int) ([]*types.Event, error)

	// Transactional operations
	Transaction(ctx context.Context, fn func(tx StateManager) error) error
}

StateManager defines the interface for state management

type Store

type Store interface {
	StateManager

	// Initialize the store
	Initialize(ctx context.Context) error

	// Close the store
	Close(ctx context.Context) error

	// Health check
	HealthCheck(ctx context.Context) error
}

Store defines the backend storage interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL