utils

package
v0.0.0-...-6dcdff4 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginContextMDKey = "plugin_context"
)

Variables

View Source
var ErrNoPluginContextError = errors.New("no plugin context in metadata")

ErrNoPluginContextError is returned when the plugin context is not found in the metadata.

Functions

func ConvertAnyToInterface

func ConvertAnyToInterface(anyValue *anypb.Any) (interface{}, error)

func ConvertInterfaceToAny

func ConvertInterfaceToAny(v interface{}) (*anypb.Any, error)

func DeexpandTilde

func DeexpandTilde(path string) string

DeexpandTilde takes a path and if it is in the home directory, it will replace it with a ~.

func ExpandTilde

func ExpandTilde(path string) (string, error)

ExpandTilde takes a path and if it starts with a ~, it will replace it with the home directory.

func GetPluginStorePath

func GetPluginStorePath(pluginID string) (string, error)

GetPluginStorePath returns the path to the plugin store for the given plugin.

func GetStore

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

getStore returns a file handle to the store for the given plugin and capability. If the store does not exist, it will be created. Make sure to close the file handle after using it!

func InitializePluginStore

func InitializePluginStore(pluginID string) error

initializeStore creates the store directory for the given plugin and capability.

func RegisterServerOpts

func RegisterServerOpts(opts []grpc.ServerOption) []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 the store for the given plugin and capability.

func ServerPluginContextInterceptor

func ServerPluginContextInterceptor(
	ctx context.Context,
	req interface{},
	_ *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

ServerPluginContextInterceptor is a gRPC server interceptor that extracts the plugin context from the metadata and attaches it to the context.

func UseServerPluginContext

func UseServerPluginContext(ctx context.Context) (context.Context, error)

UseServerPluginContext extracts the plugin context from the gRPC metadata and attaches it to the context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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