hostfunctions

package
v0.90.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBSecretsManager

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

DBSecretsManager implements SecretsManager using the database.

func NewDBSecretsManager

func NewDBSecretsManager(db rqlite.Client, encryptionKeyHex string, logger *zap.Logger) (*DBSecretsManager, error)

NewDBSecretsManager creates a secrets manager backed by the database.

func (*DBSecretsManager) Delete

func (s *DBSecretsManager) Delete(ctx context.Context, namespace, name string) error

Delete removes a secret.

func (*DBSecretsManager) Get

func (s *DBSecretsManager) Get(ctx context.Context, namespace, name string) (string, error)

Get retrieves a decrypted secret.

func (*DBSecretsManager) List

func (s *DBSecretsManager) List(ctx context.Context, namespace string) ([]string, error)

List returns all secret names for a namespace.

func (*DBSecretsManager) Set

func (s *DBSecretsManager) Set(ctx context.Context, namespace, name, value string) error

Set stores an encrypted secret.

type HostFunctions

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

HostFunctions provides the bridge between WASM functions and Orama services. It implements the HostServices interface and is injected into the execution context.

func NewHostFunctions

func NewHostFunctions(
	db rqlite.Client,
	cacheClient olriclib.Client,
	storage ipfs.IPFSClient,
	pubsubAdapter *pubsub.ClientAdapter,
	wsManager serverless.WebSocketManager,
	secrets serverless.SecretsManager,
	cfg HostFunctionsConfig,
	logger *zap.Logger,
) *HostFunctions

NewHostFunctions creates a new HostFunctions instance.

func (*HostFunctions) CacheDelete

func (h *HostFunctions) CacheDelete(ctx context.Context, key string) error

CacheDelete removes a value from the cache.

func (*HostFunctions) CacheGet

func (h *HostFunctions) CacheGet(ctx context.Context, key string) ([]byte, error)

CacheGet retrieves a value from the cache.

func (*HostFunctions) CacheIncr

func (h *HostFunctions) CacheIncr(ctx context.Context, key string) (int64, error)

CacheIncr atomically increments a numeric value in cache by 1 and returns the new value. If the key doesn't exist, it is initialized to 0 before incrementing. Returns an error if the value exists but is not numeric.

func (*HostFunctions) CacheIncrBy

func (h *HostFunctions) CacheIncrBy(ctx context.Context, key string, delta int64) (int64, error)

CacheIncrBy atomically increments a numeric value by delta and returns the new value. If the key doesn't exist, it is initialized to 0 before incrementing. Returns an error if the value exists but is not numeric.

func (*HostFunctions) CacheSet

func (h *HostFunctions) CacheSet(ctx context.Context, key string, value []byte, ttlSeconds int64) error

CacheSet stores a value in the cache with optional TTL. Note: TTL is currently not supported by the underlying Olric DMap.Put method. Values are stored indefinitely until explicitly deleted.

func (*HostFunctions) ClearContext

func (h *HostFunctions) ClearContext()

ClearContext clears the invocation context after execution.

func (*HostFunctions) DBExecute

func (h *HostFunctions) DBExecute(ctx context.Context, query string, args []interface{}) (int64, error)

DBExecute executes an INSERT/UPDATE/DELETE query and returns affected rows.

func (*HostFunctions) DBQuery

func (h *HostFunctions) DBQuery(ctx context.Context, query string, args []interface{}) ([]byte, error)

DBQuery executes a SELECT query and returns JSON-encoded results.

func (*HostFunctions) EnqueueBackground

func (h *HostFunctions) EnqueueBackground(ctx context.Context, functionName string, payload []byte) (string, error)

EnqueueBackground queues a function for background execution.

func (*HostFunctions) GetCallerWallet

func (h *HostFunctions) GetCallerWallet(ctx context.Context) string

GetCallerWallet returns the wallet address of the caller.

func (*HostFunctions) GetEnv

func (h *HostFunctions) GetEnv(ctx context.Context, key string) (string, error)

GetEnv retrieves an environment variable for the function.

func (*HostFunctions) GetLogs

func (h *HostFunctions) GetLogs() []serverless.LogEntry

GetLogs returns the captured logs for the current invocation.

func (*HostFunctions) GetRequestID

func (h *HostFunctions) GetRequestID(ctx context.Context) string

GetRequestID returns the current request ID.

func (*HostFunctions) GetSecret

func (h *HostFunctions) GetSecret(ctx context.Context, name string) (string, error)

GetSecret retrieves a decrypted secret.

func (*HostFunctions) HTTPFetch

func (h *HostFunctions) HTTPFetch(ctx context.Context, method, url string, headers map[string]string, body []byte) ([]byte, error)

HTTPFetch makes an outbound HTTP request.

func (*HostFunctions) LogError

func (h *HostFunctions) LogError(ctx context.Context, message string)

LogError logs an error message.

func (*HostFunctions) LogInfo

func (h *HostFunctions) LogInfo(ctx context.Context, message string)

LogInfo logs an info message.

func (*HostFunctions) PubSubPublish

func (h *HostFunctions) PubSubPublish(ctx context.Context, topic string, data []byte) error

PubSubPublish publishes a message to a topic.

func (*HostFunctions) ScheduleOnce

func (h *HostFunctions) ScheduleOnce(ctx context.Context, functionName string, runAt time.Time, payload []byte) (string, error)

ScheduleOnce schedules a function to run once at a specific time.

func (*HostFunctions) SetInvocationContext

func (h *HostFunctions) SetInvocationContext(invCtx *serverless.InvocationContext)

SetInvocationContext sets the current invocation context. Must be called before executing a function.

func (*HostFunctions) StorageGet

func (h *HostFunctions) StorageGet(ctx context.Context, cid string) ([]byte, error)

StorageGet retrieves data from IPFS by CID.

func (*HostFunctions) StoragePut

func (h *HostFunctions) StoragePut(ctx context.Context, data []byte) (string, error)

StoragePut uploads data to IPFS and returns the CID.

func (*HostFunctions) WSBroadcast

func (h *HostFunctions) WSBroadcast(ctx context.Context, topic string, data []byte) error

WSBroadcast sends data to all WebSocket clients subscribed to a topic.

func (*HostFunctions) WSSend

func (h *HostFunctions) WSSend(ctx context.Context, clientID string, data []byte) error

WSSend sends data to a specific WebSocket client.

type HostFunctionsConfig

type HostFunctionsConfig struct {
	IPFSAPIURL  string
	HTTPTimeout time.Duration
}

HostFunctionsConfig holds configuration for HostFunctions.

Jump to

Keyboard shortcuts

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