Documentation
¶
Overview ¶
Package utils provides SDK state-store access, RPC middleware composition, and legacy encoding helpers.
Index ¶
- func ConvertAnyToInterface(anyValue *anypb.Any) (any, error)
- func ConvertInterfaceToAny(v any) (*anypb.Any, error)
- func DeexpandTilde(path string) string
- func ExpandTilde(path string) (string, error)
- func GetPluginStorePath(pluginID string) (string, error)
- func GetStore(capability, pluginID string) (*os.File, error)
- func InitializePluginStore(pluginID string) error
- func NewServerInterceptors(log logging.Logger) ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
- func RegisterServerOpts(opts []grpc.ServerOption, log logging.Logger) []grpc.ServerOption
- func RemoveStore(capability, pluginID string) error
- func StreamingMethodFilter() otelgrpc.Filter
- type StreamObs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertAnyToInterface ¶
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 ¶
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 ¶
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 ¶
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 ¶
GetPluginStorePath returns a validated store path for an installed plugin. SDK operations use directory handles rather than reopening this advisory path.
func InitializePluginStore ¶
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 ¶
RemoveStore removes only the selected plugin's capability store.
func StreamingMethodFilter ¶ added in v0.19.3
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
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
Event adds a bounded event to the open-phase span; it is a no-op after OpenDone.