Documentation
¶
Overview ¶
Package registry manages function metadata in RQLite and bytecode in IPFS.
Index ¶
- Variables
- type DeployError
- type Function
- type FunctionDefinition
- type FunctionRegistry
- type FunctionStatus
- type FunctionStore
- func (s *FunctionStore) Delete(ctx context.Context, namespace, name string, version int) error
- func (s *FunctionStore) Get(ctx context.Context, namespace, name string, version int) (*Function, error)
- func (s *FunctionStore) GetByID(ctx context.Context, id string) (*Function, error)
- func (s *FunctionStore) GetByNameInternal(ctx context.Context, namespace, name string) (*Function, error)
- func (s *FunctionStore) GetEnvVars(ctx context.Context, functionID string) (map[string]string, error)
- func (s *FunctionStore) List(ctx context.Context, namespace string) ([]*Function, error)
- func (s *FunctionStore) ListVersions(ctx context.Context, namespace, name string) ([]*Function, error)
- func (s *FunctionStore) Save(ctx context.Context, fn *FunctionDefinition, wasmCID string, ...) (*Function, error)
- func (s *FunctionStore) SaveEnvVars(ctx context.Context, functionID string, envVars map[string]string) error
- type IPFSStore
- type InvocationLogger
- type InvocationRecordData
- type LogData
- type LogEntry
- type NotFoundError
- type Registry
- func (r *Registry) Delete(ctx context.Context, namespace, name string, version int) error
- func (r *Registry) Get(ctx context.Context, namespace, name string, version int) (*Function, error)
- func (r *Registry) GetByID(ctx context.Context, id string) (*Function, error)
- func (r *Registry) GetEnvVars(ctx context.Context, functionID string) (map[string]string, error)
- func (r *Registry) GetLogs(ctx context.Context, namespace, name string, limit int) ([]LogEntry, error)
- func (r *Registry) GetWASMBytes(ctx context.Context, wasmCID string) ([]byte, error)
- func (r *Registry) List(ctx context.Context, namespace string) ([]*Function, error)
- func (r *Registry) ListVersions(ctx context.Context, namespace, name string) ([]*Function, error)
- func (r *Registry) LogInvocation(ctx context.Context, id, functionID, requestID string, triggerType interface{}, ...) error
- func (r *Registry) Register(ctx context.Context, fn *FunctionDefinition, wasmBytes []byte) (*Function, error)
- type RegistryConfig
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ErrFunctionNotFound = &NotFoundError{Resource: "function"}
Error types
var ErrVersionNotFound = &NotFoundError{Resource: "version"}
Functions ¶
This section is empty.
Types ¶
type DeployError ¶
func (*DeployError) Error ¶
func (e *DeployError) Error() string
func (*DeployError) Unwrap ¶
func (e *DeployError) Unwrap() error
type Function ¶
type Function struct {
ID string
Name string
Namespace string
Version int
WASMCID string
SourceCID string
MemoryLimitMB int
TimeoutSeconds int
IsPublic bool
RetryCount int
RetryDelaySeconds int
DLQTopic string
Status FunctionStatus
CreatedAt time.Time
UpdatedAt time.Time
CreatedBy string
}
Function represents a deployed serverless function.
type FunctionDefinition ¶
type FunctionDefinition struct {
Name string
Namespace string
Version int
MemoryLimitMB int
TimeoutSeconds int
IsPublic bool
RetryCount int
RetryDelaySeconds int
DLQTopic string
EnvVars map[string]string
}
FunctionDefinition contains the configuration for deploying a function.
type FunctionRegistry ¶
type FunctionRegistry interface {
Register(ctx context.Context, fn *FunctionDefinition, wasmBytes []byte) (*Function, error)
Get(ctx context.Context, namespace, name string, version int) (*Function, error)
List(ctx context.Context, namespace string) ([]*Function, error)
Delete(ctx context.Context, namespace, name string, version int) error
GetWASMBytes(ctx context.Context, wasmCID string) ([]byte, error)
GetLogs(ctx context.Context, namespace, name string, limit int) ([]LogEntry, error)
}
FunctionRegistry interface
type FunctionStatus ¶
type FunctionStatus string
FunctionStatus represents the current state of a deployed function.
const ( FunctionStatusActive FunctionStatus = "active" FunctionStatusInactive FunctionStatus = "inactive" FunctionStatusError FunctionStatus = "error" )
type FunctionStore ¶
type FunctionStore struct {
// contains filtered or unexported fields
}
FunctionStore handles database operations for function metadata.
func NewFunctionStore ¶
func NewFunctionStore(db rqlite.Client, logger *zap.Logger) *FunctionStore
NewFunctionStore creates a new function store.
func (*FunctionStore) Get ¶
func (s *FunctionStore) Get(ctx context.Context, namespace, name string, version int) (*Function, error)
Get retrieves a function by name and optional version.
func (*FunctionStore) GetByNameInternal ¶
func (s *FunctionStore) GetByNameInternal(ctx context.Context, namespace, name string) (*Function, error)
GetByNameInternal retrieves a function by name regardless of status.
func (*FunctionStore) GetEnvVars ¶
func (s *FunctionStore) GetEnvVars(ctx context.Context, functionID string) (map[string]string, error)
GetEnvVars retrieves environment variables for a function.
func (*FunctionStore) ListVersions ¶
func (s *FunctionStore) ListVersions(ctx context.Context, namespace, name string) ([]*Function, error)
ListVersions returns all versions of a function.
func (*FunctionStore) Save ¶
func (s *FunctionStore) Save(ctx context.Context, fn *FunctionDefinition, wasmCID string, existingFunc *Function) (*Function, error)
Save inserts or updates a function in the database.
func (*FunctionStore) SaveEnvVars ¶
func (s *FunctionStore) SaveEnvVars(ctx context.Context, functionID string, envVars map[string]string) error
SaveEnvVars saves environment variables for a function.
type IPFSStore ¶
type IPFSStore struct {
// contains filtered or unexported fields
}
IPFSStore handles IPFS storage operations for WASM bytecode.
func NewIPFSStore ¶
NewIPFSStore creates a new IPFS store.
type InvocationLogger ¶
type InvocationLogger struct {
// contains filtered or unexported fields
}
InvocationLogger handles logging of function invocations and their logs.
func NewInvocationLogger ¶
func NewInvocationLogger(db rqlite.Client, logger *zap.Logger) *InvocationLogger
NewInvocationLogger creates a new invocation logger.
func (*InvocationLogger) GetLogs ¶
func (l *InvocationLogger) GetLogs(ctx context.Context, namespace, name string, limit int) ([]LogEntry, error)
GetLogs retrieves logs for a function.
func (*InvocationLogger) Log ¶
func (l *InvocationLogger) Log(ctx context.Context, inv *InvocationRecordData) error
Log records a function invocation and its logs to the database.
type InvocationRecordData ¶
type NotFoundError ¶
type NotFoundError struct {
Resource string
}
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry coordinates between function storage, IPFS storage, and logging.
func NewRegistry ¶
func NewRegistry(db rqlite.Client, ipfsClient ipfs.IPFSClient, cfg RegistryConfig, logger *zap.Logger) *Registry
NewRegistry creates a new function registry.
func (*Registry) GetEnvVars ¶
GetEnvVars retrieves environment variables for a function.
func (*Registry) GetLogs ¶
func (r *Registry) GetLogs(ctx context.Context, namespace, name string, limit int) ([]LogEntry, error)
GetLogs retrieves logs for a function.
func (*Registry) GetWASMBytes ¶
GetWASMBytes retrieves the compiled WASM bytecode for a function.
func (*Registry) ListVersions ¶
ListVersions returns all versions of a function.
func (*Registry) LogInvocation ¶
func (r *Registry) LogInvocation(ctx context.Context, id, functionID, requestID string, triggerType interface{}, callerWallet string, inputSize, outputSize int, startedAt, completedAt interface{}, durationMS int64, status interface{}, errorMessage string, memoryUsedMB float64, logs []LogEntry) error
LogInvocation records a function invocation and its logs to the database.
type RegistryConfig ¶
type RegistryConfig struct {
IPFSAPIURL string
}
RegistryConfig holds configuration for the Registry.
type ValidationError ¶
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string