storage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const MaxKVKeyBytes = 128

Variables

View Source
var (
	ErrInvalidNamespace       = errors.New("storage namespace is invalid")
	ErrNamespaceAlreadyExists = errors.New("storage namespace already exists")
	ErrInvalidFilePath        = errors.New("storage file path is invalid")
	ErrInvalidKVKey           = errors.New("storage kv key is invalid")
	ErrInvalidSQLite          = errors.New("storage sqlite request is invalid")
	ErrNamespaceNotFound      = errors.New("storage namespace not found")
	ErrNamespaceNotRetained   = errors.New("storage namespace is not retained")
	ErrQuotaExceeded          = errors.New("storage quota exceeded")
	ErrArchiveNotFound        = errors.New("storage archive not found")
	ErrFileNotFound           = errors.New("storage file not found")
	ErrFileTooLarge           = errors.New("storage file too large")
	ErrKVKeyNotFound          = errors.New("storage kv key not found")
	ErrKVValueTooLarge        = errors.New("storage kv value too large")
	ErrSQLiteResultTooLarge   = errors.New("storage sqlite result too large")
)

Functions

This section is empty.

Types

type ArchiveRecord

type ArchiveRecord struct {
	ArchiveRef             string            `json:"archive_ref"`
	SourcePluginInstanceID string            `json:"source_plugin_instance_id"`
	IncludeSecrets         bool              `json:"include_secrets"`
	Namespaces             []NamespaceRecord `json:"namespaces"`
	CreatedAt              time.Time         `json:"created_at"`
}

type BindRetainedRequest

type BindRetainedRequest struct {
	SourcePluginInstanceID string      `json:"source_plugin_instance_id"`
	TargetPluginInstanceID string      `json:"target_plugin_instance_id"`
	TargetNamespaces       []Namespace `json:"target_namespaces,omitempty"`
	DryRun                 bool        `json:"dry_run,omitempty"`
	Now                    time.Time   `json:"now,omitempty"`
}

type Broker

type Broker interface {
	EnsureNamespace(ctx context.Context, ns Namespace) error
	DeleteNamespace(ctx context.Context, pluginInstanceID string, deleteData bool) error
	ExportData(ctx context.Context, req ExportRequest) (string, error)
	ImportData(ctx context.Context, req ImportRequest) error
}

type ExportRequest

type ExportRequest struct {
	PluginInstanceID string `json:"plugin_instance_id"`
	IncludeSecrets   bool   `json:"include_secrets"`
}

type FileBroker

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

func NewFileBroker

func NewFileBroker(root string) (*FileBroker, error)

func (*FileBroker) BindRetainedNamespace

func (b *FileBroker) BindRetainedNamespace(ctx context.Context, req BindRetainedRequest) error

func (*FileBroker) DeleteFile

func (b *FileBroker) DeleteFile(ctx context.Context, req FileDeleteRequest) error

func (*FileBroker) DeleteKV

func (b *FileBroker) DeleteKV(ctx context.Context, req KVDeleteRequest) error

func (*FileBroker) DeleteNamespace

func (b *FileBroker) DeleteNamespace(ctx context.Context, pluginInstanceID string, deleteData bool) error

func (*FileBroker) DeleteRetainedNamespace

func (b *FileBroker) DeleteRetainedNamespace(ctx context.Context, pluginInstanceID string) error

func (*FileBroker) EnsureNamespace

func (b *FileBroker) EnsureNamespace(ctx context.Context, ns Namespace) error

func (*FileBroker) ExecSQLite

func (*FileBroker) ExportData

func (b *FileBroker) ExportData(ctx context.Context, req ExportRequest) (string, error)

func (*FileBroker) GetKV

func (b *FileBroker) GetKV(ctx context.Context, req KVGetRequest) (KVGetResult, error)

func (*FileBroker) ImportData

func (b *FileBroker) ImportData(ctx context.Context, req ImportRequest) error

func (*FileBroker) ListFiles

func (b *FileBroker) ListFiles(ctx context.Context, req FileListRequest) (FileListResult, error)

func (*FileBroker) ListKV

func (b *FileBroker) ListKV(ctx context.Context, req KVListRequest) (KVListResult, error)

func (*FileBroker) ListNamespaces

func (b *FileBroker) ListNamespaces(ctx context.Context, pluginInstanceID string) ([]NamespaceRecord, error)

func (*FileBroker) NamespacePath

func (b *FileBroker) NamespacePath(ctx context.Context, pluginInstanceID string, storeID string) (string, error)

func (*FileBroker) PutKV

func (b *FileBroker) PutKV(ctx context.Context, req KVPutRequest) (KVPutResult, error)

func (*FileBroker) QuerySQLite

func (*FileBroker) ReadFile

func (b *FileBroker) ReadFile(ctx context.Context, req FileReadRequest) (FileReadResult, error)

func (*FileBroker) Root

func (b *FileBroker) Root() string

func (*FileBroker) Usage

func (b *FileBroker) Usage(ctx context.Context, pluginInstanceID string, storeID string) (Usage, error)

func (*FileBroker) WriteFile

func (b *FileBroker) WriteFile(ctx context.Context, req FileWriteRequest) (FileWriteResult, error)

type FileDeleteRequest

type FileDeleteRequest struct {
	PluginInstanceID string `json:"plugin_instance_id"`
	StoreID          string `json:"store_id"`
	Path             string `json:"path"`
	Recursive        bool   `json:"recursive,omitempty"`
}

type FileEntry

type FileEntry struct {
	Path      string    `json:"path"`
	Dir       bool      `json:"dir"`
	SizeBytes int64     `json:"size_bytes,omitempty"`
	UpdatedAt time.Time `json:"updated_at"`
}

type FileListRequest

type FileListRequest struct {
	PluginInstanceID string `json:"plugin_instance_id"`
	StoreID          string `json:"store_id"`
	Path             string `json:"path,omitempty"`
	MaxEntries       int    `json:"max_entries,omitempty"`
}

type FileListResult

type FileListResult struct {
	Path    string      `json:"path"`
	Entries []FileEntry `json:"entries"`
	Usage   Usage       `json:"usage"`
}

type FileReadRequest

type FileReadRequest struct {
	PluginInstanceID string `json:"plugin_instance_id"`
	StoreID          string `json:"store_id"`
	Path             string `json:"path"`
	MaxBytes         int64  `json:"max_bytes,omitempty"`
}

type FileReadResult

type FileReadResult struct {
	Path      string `json:"path"`
	Data      []byte `json:"-"`
	SizeBytes int64  `json:"size_bytes"`
	Usage     Usage  `json:"usage"`
}

type FileWriteRequest

type FileWriteRequest struct {
	PluginInstanceID string `json:"plugin_instance_id"`
	StoreID          string `json:"store_id"`
	Path             string `json:"path"`
	Data             []byte `json:"-"`
}

type FileWriteResult

type FileWriteResult struct {
	Path      string `json:"path"`
	SizeBytes int64  `json:"size_bytes"`
	Usage     Usage  `json:"usage"`
}

type FilesBroker

type FilesBroker interface {
	ReadFile(ctx context.Context, req FileReadRequest) (FileReadResult, error)
	WriteFile(ctx context.Context, req FileWriteRequest) (FileWriteResult, error)
	DeleteFile(ctx context.Context, req FileDeleteRequest) error
	ListFiles(ctx context.Context, req FileListRequest) (FileListResult, error)
}

type ImportRequest

type ImportRequest struct {
	PluginInstanceID string      `json:"plugin_instance_id"`
	ArchiveRef       string      `json:"archive_ref"`
	DeleteExisting   bool        `json:"delete_existing"`
	TargetNamespaces []Namespace `json:"target_namespaces,omitempty"`
}

type Inspector

type Inspector interface {
	ListNamespaces(ctx context.Context, pluginInstanceID string) ([]NamespaceRecord, error)
	Usage(ctx context.Context, pluginInstanceID string, storeID string) (Usage, error)
}

type KVBroker

type KVBroker interface {
	GetKV(ctx context.Context, req KVGetRequest) (KVGetResult, error)
	PutKV(ctx context.Context, req KVPutRequest) (KVPutResult, error)
	DeleteKV(ctx context.Context, req KVDeleteRequest) error
	ListKV(ctx context.Context, req KVListRequest) (KVListResult, error)
}

type KVDeleteRequest

type KVDeleteRequest struct {
	PluginInstanceID string `json:"plugin_instance_id"`
	StoreID          string `json:"store_id"`
	Key              string `json:"key"`
}

type KVEntry

type KVEntry struct {
	Key       string    `json:"key"`
	SizeBytes int64     `json:"size_bytes"`
	UpdatedAt time.Time `json:"updated_at"`
}

type KVGetRequest

type KVGetRequest struct {
	PluginInstanceID string `json:"plugin_instance_id"`
	StoreID          string `json:"store_id"`
	Key              string `json:"key"`
	MaxBytes         int64  `json:"max_bytes,omitempty"`
}

type KVGetResult

type KVGetResult struct {
	Key       string `json:"key"`
	Value     []byte `json:"-"`
	SizeBytes int64  `json:"size_bytes"`
	Usage     Usage  `json:"usage"`
}

type KVListRequest

type KVListRequest struct {
	PluginInstanceID string `json:"plugin_instance_id"`
	StoreID          string `json:"store_id"`
	Prefix           string `json:"prefix,omitempty"`
	MaxEntries       int    `json:"max_entries,omitempty"`
}

type KVListResult

type KVListResult struct {
	Prefix  string    `json:"prefix,omitempty"`
	Entries []KVEntry `json:"entries"`
	Usage   Usage     `json:"usage"`
}

type KVPutRequest

type KVPutRequest struct {
	PluginInstanceID string `json:"plugin_instance_id"`
	StoreID          string `json:"store_id"`
	Key              string `json:"key"`
	Value            []byte `json:"-"`
}

type KVPutResult

type KVPutResult struct {
	Key       string `json:"key"`
	SizeBytes int64  `json:"size_bytes"`
	Usage     Usage  `json:"usage"`
}

type MemoryBroker

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

func NewMemoryBroker

func NewMemoryBroker() *MemoryBroker

func (*MemoryBroker) Archive

func (b *MemoryBroker) Archive(ref string) (ArchiveRecord, bool)

func (*MemoryBroker) BindRetainedNamespace

func (b *MemoryBroker) BindRetainedNamespace(_ context.Context, req BindRetainedRequest) error

func (*MemoryBroker) DeleteKV

func (b *MemoryBroker) DeleteKV(_ context.Context, req KVDeleteRequest) error

func (*MemoryBroker) DeleteNamespace

func (b *MemoryBroker) DeleteNamespace(_ context.Context, pluginInstanceID string, deleteData bool) error

func (*MemoryBroker) DeleteRetainedNamespace

func (b *MemoryBroker) DeleteRetainedNamespace(_ context.Context, pluginInstanceID string) error

func (*MemoryBroker) EnsureNamespace

func (b *MemoryBroker) EnsureNamespace(_ context.Context, ns Namespace) error

func (*MemoryBroker) ExportData

func (b *MemoryBroker) ExportData(_ context.Context, req ExportRequest) (string, error)

func (*MemoryBroker) GetKV

func (*MemoryBroker) ImportData

func (b *MemoryBroker) ImportData(_ context.Context, req ImportRequest) error

func (*MemoryBroker) ListKV

func (*MemoryBroker) ListNamespaces

func (b *MemoryBroker) ListNamespaces(_ context.Context, pluginInstanceID string) ([]NamespaceRecord, error)

func (*MemoryBroker) PutKV

func (*MemoryBroker) SetUsage

func (b *MemoryBroker) SetUsage(_ context.Context, pluginInstanceID string, storeID string, usageBytes int64) error

func (*MemoryBroker) Usage

func (b *MemoryBroker) Usage(_ context.Context, pluginInstanceID string, storeID string) (Usage, error)

type Namespace

type Namespace struct {
	PluginInstanceID string    `json:"plugin_instance_id"`
	StoreID          string    `json:"store_id"`
	Kind             StoreKind `json:"kind"`
	Scope            string    `json:"scope,omitempty"`
	QuotaBytes       int64     `json:"quota_bytes"`
	QuotaFiles       int64     `json:"quota_files,omitempty"`
	SchemaVersion    int       `json:"schema_version,omitempty"`
}

type NamespacePathResolver

type NamespacePathResolver interface {
	NamespacePath(ctx context.Context, pluginInstanceID string, storeID string) (string, error)
}

type NamespaceRecord

type NamespaceRecord struct {
	Namespace
	State      NamespaceState `json:"state"`
	UsageBytes int64          `json:"usage_bytes"`
	UsageFiles int64          `json:"usage_files,omitempty"`
	CreatedAt  time.Time      `json:"created_at"`
	UpdatedAt  time.Time      `json:"updated_at"`
	RetainedAt *time.Time     `json:"retained_at,omitempty"`
}

type NamespaceState

type NamespaceState string
const (
	NamespaceActive   NamespaceState = "active"
	NamespaceRetained NamespaceState = "retained"
)

type RetainedBinder

type RetainedBinder interface {
	BindRetainedNamespace(ctx context.Context, req BindRetainedRequest) error
}

type RetainedDeleter

type RetainedDeleter interface {
	DeleteRetainedNamespace(ctx context.Context, pluginInstanceID string) error
}

type SQLiteBroker

type SQLiteBroker interface {
	ExecSQLite(ctx context.Context, req SQLiteExecRequest) (SQLiteExecResult, error)
	QuerySQLite(ctx context.Context, req SQLiteQueryRequest) (SQLiteQueryResult, error)
}

type SQLiteExecRequest

type SQLiteExecRequest struct {
	PluginInstanceID string        `json:"plugin_instance_id"`
	StoreID          string        `json:"store_id"`
	Database         string        `json:"database,omitempty"`
	SQL              string        `json:"sql"`
	Args             []SQLiteValue `json:"args,omitempty"`
	Timeout          time.Duration `json:"timeout,omitempty"`
}

type SQLiteExecResult

type SQLiteExecResult struct {
	Database     string `json:"database"`
	RowsAffected int64  `json:"rows_affected"`
	LastInsertID int64  `json:"last_insert_id,omitempty"`
	Usage        Usage  `json:"usage"`
}

type SQLiteQueryRequest

type SQLiteQueryRequest struct {
	PluginInstanceID string        `json:"plugin_instance_id"`
	StoreID          string        `json:"store_id"`
	Database         string        `json:"database,omitempty"`
	SQL              string        `json:"sql"`
	Args             []SQLiteValue `json:"args,omitempty"`
	MaxRows          int           `json:"max_rows,omitempty"`
	MaxResponseBytes int64         `json:"max_response_bytes,omitempty"`
	Timeout          time.Duration `json:"timeout,omitempty"`
}

type SQLiteQueryResult

type SQLiteQueryResult struct {
	Database string          `json:"database"`
	Columns  []string        `json:"columns"`
	Rows     [][]SQLiteValue `json:"rows"`
	Usage    Usage           `json:"usage"`
}

type SQLiteValue

type SQLiteValue struct {
	Null  bool     `json:"null,omitempty"`
	Int   *int64   `json:"int,omitempty"`
	Float *float64 `json:"float,omitempty"`
	Text  *string  `json:"text,omitempty"`
	Blob  []byte   `json:"-"`
}

type StoreKind

type StoreKind string
const (
	StoreKV     StoreKind = "kv"
	StoreFiles  StoreKind = "files"
	StoreSQLite StoreKind = "sqlite"
)

type Usage

type Usage struct {
	PluginInstanceID string `json:"plugin_instance_id"`
	StoreID          string `json:"store_id"`
	UsageBytes       int64  `json:"usage_bytes"`
	QuotaBytes       int64  `json:"quota_bytes"`
	UsageFiles       int64  `json:"usage_files"`
	QuotaFiles       int64  `json:"quota_files"`
}

Jump to

Keyboard shortcuts

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