utils

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: AGPL-3.0 Imports: 22 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package utils provides SDK state-store access, RPC middleware composition, and legacy encoding helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAnyToInterface

func ConvertAnyToInterface(anyValue *anypb.Any) (any, error)

ConvertAnyToInterface decodes a JSON BytesValue envelope into ordinary Go JSON values. Malformed envelopes or JSON return an error; JSON null produces a nil value without error.

func ConvertInterfaceToAny

func ConvertInterfaceToAny(v any) (*anypb.Any, error)

ConvertInterfaceToAny encodes v as JSON inside a protobuf BytesValue envelope. Unsupported JSON values retain the legacy empty-body behavior; this is not a resource-value codec.

func DeexpandTilde

func DeexpandTilde(path string) string

DeexpandTilde replaces HOME or its lexical path-component prefix with "~". Other paths and failed HOME lookups remain unchanged; it does not resolve symlinks.

func ExpandTilde

func ExpandTilde(path string) (string, error)

ExpandTilde expands paths beginning with "~/" using the current home directory. Other inputs, including empty strings and bare "~", remain unchanged. HOME lookup errors are returned.

func GetPluginStorePath

func GetPluginStorePath(pluginID string) (string, error)

GetPluginStorePath returns a validated store path for an installed plugin. SDK operations use directory handles rather than reopening this advisory path.

func GetStore

func GetStore(capability, pluginID string) (*os.File, error)

GetStore opens a capability store, creating it if needed. The caller closes it.

func InitializePluginStore

func InitializePluginStore(pluginID string) error

InitializePluginStore creates the private store for an installed plugin.

func NewServerInterceptors

func NewServerInterceptors(log logging.Logger) ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)

NewServerInterceptors returns the default unary and stream interceptor chains for the plugin SDK gRPC server.

func RegisterServerOpts

func RegisterServerOpts(opts []grpc.ServerOption, log logging.Logger) []grpc.ServerOption

RegisterServerOpts returns a list of gRPC server options with the necessary interceptors for the plugin SDK.

func RemoveStore

func RemoveStore(capability, pluginID string) error

RemoveStore removes only the selected plugin's capability store.

func StreamingMethodFilter added in v0.19.3

func StreamingMethodFilter() otelgrpc.Filter

StreamingMethodFilter returns an otelgrpc Filter that skips long-lived streaming RPCs. These streams can run for the entire plugin lifetime and would produce never-ending spans, so they are covered by manual open-phase spans instead. Short-lived unary RPCs are always traced. It is the single list used by both server and client stats handlers.

Types

type StreamObs added in v0.19.3

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

StreamObs observes one long-lived server stream. The span covers only the open/setup phase; closing the stream records a Debug log and releases the stream gauge. It never records payloads or error text.

func BeginStream added in v0.19.3

func BeginStream(ctx context.Context, log logging.Logger, service, op string) (context.Context, *StreamObs)

BeginStream starts the "sdk.<service>.open" span and registers the stream with the sdk.streams gauge. op must be a vocabulary value accepted by obs.StreamOpened. Call OpenDone or OpenFailed exactly once, then Close.

func (*StreamObs) Close added in v0.19.3

func (s *StreamObs) Close(ctx context.Context, err error)

Close releases the stream gauge and logs the classified end of the stream. io.EOF is the normal client close and is reported as a clean end.

func (*StreamObs) Event added in v0.19.3

func (s *StreamObs) Event(name string, attrs ...attribute.KeyValue)

Event adds a bounded event to the open-phase span; it is a no-op after OpenDone.

func (*StreamObs) OpenDone added in v0.19.3

func (s *StreamObs) OpenDone()

OpenDone ends the open-phase span successfully.

func (*StreamObs) OpenFailed added in v0.19.3

func (s *StreamObs) OpenFailed(ctx context.Context, err error)

OpenFailed ends the open-phase span with a classified failure and logs it.

Directories

Path Synopsis
Package timeutil provides shared time abstractions for deterministic testing.
Package timeutil provides shared time abstractions for deterministic testing.

Jump to

Keyboard shortcuts

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