engine

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrQuotaExceeded = fmt.Errorf("quota exceeded")
	ErrInvalidInput  = fmt.Errorf("invalid input")
	ErrTimeout       = fmt.Errorf("operation timeout")
)

Common errors

Functions

func ErrNotFound

func ErrNotFound(container, artifact string) error

func ErrPermissionDenied

func ErrPermissionDenied(tenantID, action string) error

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) (string, bool)

func TenantIDFromContext

func TenantIDFromContext(ctx context.Context) (string, bool)

func WithRequestID

func WithRequestID(ctx context.Context, requestID string) context.Context

func WithTenantID

func WithTenantID(ctx context.Context, tenantID string) context.Context

func WrapError

func WrapError(err error, message string) error

Types

type AccessEvent

type AccessEvent struct {
	Container string
	Artifact  string
	Operation string
	Timestamp time.Time
	Latency   time.Duration
	Size      int64
	Success   bool
}

AccessEvent for ML training data

type Artifact

type Artifact struct {
	ID        string                 `json:"id"`
	Container string                 `json:"container"`
	Key       string                 `json:"key"`
	Type      string                 `json:"type"` // "blob", "wasm", "model", "vector", "dataset"
	Size      int64                  `json:"size"`
	Modified  time.Time              `json:"modified"`
	ETag      string                 `json:"etag"`
	Metadata  map[string]interface{} `json:"metadata"`

	// Hidden ML/AI fields
	Features    map[string]float64 `json:"-"` // For ML training
	Vector      []float64          `json:"-"` // For similarity search
	AccessCount int64              `json:"-"` // For smart caching
	LastAccess  time.Time          `json:"-"` // For tiering decisions
}

Artifact replaces Object - ready for any data type

type ComputeEngine

type ComputeEngine interface {
	LoadModule(wasm []byte) error
	Execute(input []byte) ([]byte, error)
}

ComputeEngine for WASM execution (future use)

type Container

type Container struct {
	ID       string                 `json:"id"`
	Name     string                 `json:"name"`
	Type     string                 `json:"type"` // "storage", "compute", "ml-model", "vector-db"
	Created  time.Time              `json:"created"`
	Metadata map[string]interface{} `json:"metadata"`

	// Hidden ML fields (not exposed in S3 API)
	Temperature float64 `json:"-"` // Access frequency score
	Tier        string  `json:"-"` // "hot", "warm", "cold", "archive"
}

Container replaces Bucket - ready for compute/ML workloads

type CoreEngine

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

CoreEngine implements the Engine interface

func NewEngine

func NewEngine(logger *zap.Logger) *CoreEngine

NewEngine creates a new engine instance

func (*CoreEngine) AddDriver

func (e *CoreEngine) AddDriver(name string, driver Driver)

AddDriver adds a storage driver

func (*CoreEngine) Delete

func (e *CoreEngine) Delete(ctx context.Context, container, artifact string) error

Delete removes an artifact (S3 DeleteObject)

func (*CoreEngine) Execute

func (e *CoreEngine) Execute(ctx context.Context, container string, wasm []byte, input io.Reader) (io.Reader, error)

Hidden WASM execution (returns error for now)

func (*CoreEngine) Get

func (e *CoreEngine) Get(ctx context.Context, container, artifact string) (io.ReadCloser, error)

Get retrieves an artifact (S3 GetObject)

func (*CoreEngine) GetArtifactMetadata

func (e *CoreEngine) GetArtifactMetadata(ctx context.Context, container, artifact string) (*Artifact, error)

GetArtifactMetadata returns artifact metadata

func (*CoreEngine) GetContainerMetadata

func (e *CoreEngine) GetContainerMetadata(ctx context.Context, container string) (*Container, error)

GetContainerMetadata returns container metadata

func (*CoreEngine) GetMetrics

func (e *CoreEngine) GetMetrics(ctx context.Context) (map[string]interface{}, error)

GetMetrics returns engine metrics

func (*CoreEngine) HealthCheck

func (e *CoreEngine) HealthCheck(ctx context.Context) error

HealthCheck verifies all drivers are healthy

func (*CoreEngine) List

func (e *CoreEngine) List(ctx context.Context, container, prefix string) ([]Artifact, error)

List returns artifacts in a container (S3 ListObjects)

func (*CoreEngine) Predict

func (e *CoreEngine) Predict(ctx context.Context, model string, input []byte) ([]byte, error)

Hidden ML prediction (returns error for now)

func (*CoreEngine) Put

func (e *CoreEngine) Put(ctx context.Context, container, artifact string, data io.Reader, opts ...PutOption) error

Put stores an artifact (S3 PutObject)

func (*CoreEngine) Query

func (e *CoreEngine) Query(ctx context.Context, sql string) (ResultSet, error)

Hidden SQL query (returns error for now)

func (*CoreEngine) SetBackup

func (e *CoreEngine) SetBackup(name string)

SetBackup sets the backup driver

func (*CoreEngine) SetPrimary

func (e *CoreEngine) SetPrimary(name string)

SetPrimary sets the primary driver

func (*CoreEngine) Train

func (e *CoreEngine) Train(ctx context.Context, model string, data []byte) error

Hidden ML training (returns error for now)

type Driver

type Driver interface {
	Name() string
	Get(ctx context.Context, container, artifact string) (io.ReadCloser, error)
	Put(ctx context.Context, container, artifact string, data io.Reader, opts ...PutOption) error
	Delete(ctx context.Context, container, artifact string) error
	List(ctx context.Context, container, prefix string) ([]string, error)
	HealthCheck(ctx context.Context) error
}

Driver interface for storage backends - FIXED to use container/artifact

type Engine

type Engine interface {
	// Storage operations (visible to users)
	Get(ctx context.Context, container, artifact string) (io.ReadCloser, error)
	Put(ctx context.Context, container, artifact string, data io.Reader, opts ...PutOption) error
	Delete(ctx context.Context, container, artifact string) error
	List(ctx context.Context, container, prefix string) ([]Artifact, error)

	// Hidden capabilities (implement as no-ops for now)
	Execute(ctx context.Context, container string, wasm []byte, input io.Reader) (io.Reader, error)
	Query(ctx context.Context, sql string) (ResultSet, error)
	Train(ctx context.Context, model string, data []byte) error
	Predict(ctx context.Context, model string, input []byte) ([]byte, error)

	// Metadata operations
	GetContainerMetadata(ctx context.Context, container string) (*Container, error)
	GetArtifactMetadata(ctx context.Context, container, artifact string) (*Artifact, error)

	// Health and metrics
	HealthCheck(ctx context.Context) error
	GetMetrics(ctx context.Context) (map[string]interface{}, error)
}

Engine is the universal interface for storage, compute, and ML

type MLEngine

type MLEngine interface {
	LoadModel(path string) error
	Train(data [][]float64, labels []float64) error
	Predict(input []float64) (float64, error)
}

MLEngine for machine learning operations (future use)

type NotFoundError

type NotFoundError struct {
	Container string
	Artifact  string
}

func (NotFoundError) Error

func (e NotFoundError) Error() string

type Operation

type Operation struct {
	Type      string // "get", "put", "delete", "compute", "query"
	Container string
	Artifact  string
	Context   context.Context
	Metadata  map[string]interface{}
}

Operation represents any engine operation (not just storage)

type PermissionError

type PermissionError struct {
	TenantID string
	Action   string
}

func (PermissionError) Error

func (e PermissionError) Error() string

type PutOption

type PutOption func(*PutOptions)

PutOption is a function that configures Put operations

func WithContentType

func WithContentType(ct string) PutOption

WithContentType sets the content type

func WithUserMetadata

func WithUserMetadata(meta map[string]string) PutOption

WithUserMetadata sets user metadata

type PutOptions

type PutOptions struct {
	ContentType     string
	CacheControl    string
	ContentEncoding string
	ContentLanguage string
	UserMetadata    map[string]string
}

PutOptions holds options for Put operations

type Result

type Result struct {
	Success  bool
	Data     io.ReadCloser
	Metadata map[string]interface{}
	Error    error
}

Result can hold any operation result

type ResultSet

type ResultSet interface {
	Next() bool
	Scan(dest ...interface{}) error
	Close() error
}

ResultSet for query operations (future use)

Jump to

Keyboard shortcuts

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