wasmcontext

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package wasmcontext provides context propagation utilities for the Reglet SDK. It handles converting between Go contexts and the wire format used for WASM host function calls.

Index

Constants

View Source
const RequestIDKey contextKey = "request_id"

RequestIDKey is the context key for request ID.

Variables

This section is empty.

Functions

func ContextToWire

func ContextToWire(ctx stdcontext.Context) entities.ContextWire

ContextToWire converts a stdcontext.Context to ContextWireFormat for sending to the host via host functions.

It extracts: - Deadline (timeout) - Cancellation status - Request ID (key: RequestIDKey)

func GetCurrentContext

func GetCurrentContext() stdcontext.Context

GetCurrentContext returns the current execution context.

This is used by SDK functions (exec, net, log) to get the context for host function calls. If no context has been set, it returns context.Background().

func ResetContext

func ResetContext()

ResetContext resets the global context to background.

This helper function simplifies the cleanup pattern in the plugin lifecyle. It should be called (usually via defer) after an operation completes.

func SetCurrentContext

func SetCurrentContext(ctx stdcontext.Context)

SetCurrentContext sets the current execution context.

This is called by the plugin infrastructure when the host invokes an exported function (describe, schema, observe). It updates the global context used for the duration of the execution.

func WireToContext

WireToContext converts a ContextWireFormat to a stdcontext.Context. This is used when the host provides context information to the plugin.

If parent is nil, context.Background() is used. Returns the new context and its CancelFunc.

Types

This section is empty.

Jump to

Keyboard shortcuts

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