storage

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDBConnection    = errors.New("database connection error")
	ErrDBQuery         = errors.New("database query error")
	ErrDBScan          = errors.New("database scan error")
	ErrMigration       = errors.New("database migration error")
	ErrCreate          = errors.New("create error")
	ErrUpdate          = errors.New("update error")
	ErrDelete          = errors.New("delete error")
	ErrInvalidID       = errors.New("invalid ID")
	ErrTaskNotFound    = errors.New("task not found")
	ErrPropletNotFound = errors.New("proplet not found")
	ErrNotFound        = errors.New("not found")
)

Functions

This section is empty.

Types

type Config added in v0.4.0

type Config struct {
	Type string `env:"MANAGER_STORAGE_TYPE" envDefault:"memory"`

	PostgresHost    string `env:"MANAGER_POSTGRES_HOST"    envDefault:"localhost"`
	PostgresPort    string `env:"MANAGER_POSTGRES_PORT"    envDefault:"5432"`
	PostgresUser    string `env:"MANAGER_POSTGRES_USER"    envDefault:"propeller"`
	PostgresPass    string `env:"MANAGER_POSTGRES_PASS"    envDefault:"propeller"`
	PostgresDB      string `env:"MANAGER_POSTGRES_DB"      envDefault:"propeller"`
	PostgresSSLMode string `env:"MANAGER_POSTGRES_SSLMODE" envDefault:"disable"`

	SQLitePath string `env:"MANAGER_SQLITE_PATH" envDefault:"./propeller.db"`

	BadgerPath string `env:"MANAGER_BADGER_PATH" envDefault:"./data/badger"`
}

type JobRepository added in v0.4.0

type JobRepository interface {
	Create(ctx context.Context, j job.Job) (job.Job, error)
	Get(ctx context.Context, id string) (job.Job, error)
	List(ctx context.Context, offset, limit uint64) ([]job.Job, uint64, error)
	Delete(ctx context.Context, id string) error
}

type MetricsRepository added in v0.4.0

type MetricsRepository interface {
	CreateTaskMetrics(ctx context.Context, m TaskMetrics) error
	CreatePropletMetrics(ctx context.Context, m PropletMetrics) error
	ListTaskMetrics(ctx context.Context, taskID string, offset, limit uint64) ([]TaskMetrics, uint64, error)
	ListPropletMetrics(ctx context.Context, propletID string, offset, limit uint64) ([]PropletMetrics, uint64, error)
}

type PropletMetrics added in v0.4.0

type PropletMetrics struct {
	PropletID string                `json:"proplet_id"`
	Namespace string                `json:"namespace"`
	Timestamp time.Time             `json:"timestamp"`
	CPU       proplet.CPUMetrics    `json:"cpu_metrics"`
	Memory    proplet.MemoryMetrics `json:"memory_metrics"`
}

type PropletRepository added in v0.4.0

type PropletRepository interface {
	Create(ctx context.Context, p proplet.Proplet) error
	Get(ctx context.Context, id string) (proplet.Proplet, error)
	Update(ctx context.Context, p proplet.Proplet) error
	List(ctx context.Context, offset, limit uint64) ([]proplet.Proplet, uint64, error)
	Delete(ctx context.Context, id string) error
}

type Repositories added in v0.4.0

type Repositories struct {
	Tasks        TaskRepository
	Proplets     PropletRepository
	TaskProplets TaskPropletRepository
	Jobs         JobRepository
	Metrics      MetricsRepository
	// Closer closes the underlying persistent storage connection.
	// It is nil for the in-memory backend.
	Closer io.Closer
}

func NewRepositories added in v0.4.0

func NewRepositories(cfg Config) (*Repositories, error)

type Storage

type Storage interface {
	Create(ctx context.Context, key string, value any) error
	Get(ctx context.Context, key string) (any, error)
	Update(ctx context.Context, key string, value any) error
	List(ctx context.Context, offset, limit uint64) ([]any, uint64, error)
	Delete(ctx context.Context, key string) error
}

Storage is a generic key-value storage interface used internally by storage adapters. It is an implementation detail and should not be used directly outside of the storage package. Use the typed repository interfaces (TaskRepository, PropletRepository, etc.) instead.

For memory storage implementations, note that List operations may have performance limitations due to in-memory filtering. See memory_adapter.go for details.

func NewInMemoryStorage

func NewInMemoryStorage() Storage

type TaskMetrics added in v0.4.0

type TaskMetrics struct {
	TaskID     string                     `json:"task_id"`
	PropletID  string                     `json:"proplet_id"`
	Metrics    proplet.ProcessMetrics     `json:"metrics"`
	Aggregated *proplet.AggregatedMetrics `json:"aggregated,omitempty"`
	Timestamp  time.Time                  `json:"timestamp"`
}

type TaskPropletRepository added in v0.4.0

type TaskPropletRepository interface {
	Create(ctx context.Context, taskID, propletID string) error
	Get(ctx context.Context, taskID string) (string, error)
	Delete(ctx context.Context, taskID string) error
}

type TaskRepository added in v0.4.0

type TaskRepository interface {
	Create(ctx context.Context, t task.Task) (task.Task, error)
	Get(ctx context.Context, id string) (task.Task, error)
	Update(ctx context.Context, t task.Task) error
	List(ctx context.Context, offset, limit uint64) ([]task.Task, uint64, error)
	ListByWorkflowID(ctx context.Context, workflowID string) ([]task.Task, error)
	ListByJobID(ctx context.Context, jobID string) ([]task.Task, error)
	Delete(ctx context.Context, id string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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