functions

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateGRPCServer

func CreateGRPCServer(registry *Registry) *grpc.Server

CreateGRPCServer creates and configures a gRPC server

func GetModuleName

func GetModuleName() (string, error)

GetModuleName reads the module name from go.mod

func RegisterGlobalFunction

func RegisterGlobalFunction(serviceName, functionName string, fn interface{}) error

RegisterGlobalFunction allows user packages to register their functions

Types

type FunctionMeta

type FunctionMeta struct {
	Name        string
	ServiceName string
	Package     string
	Function    reflect.Value
	Type        reflect.Type
	ArgTypes    []string
	ReturnType  string
	Description string
}

FunctionMeta contains metadata about a server function

type GRPCServer

type GRPCServer struct {
	pb.UnimplementedFunctionServiceServer
	// contains filtered or unexported fields
}

GRPCServer implements the FunctionService gRPC interface

func NewGRPCServer

func NewGRPCServer(registry *Registry) *GRPCServer

NewGRPCServer creates a new gRPC server with the function registry

func (*GRPCServer) Call

Call implements the Call RPC method

func (*GRPCServer) CallStream

CallStream implements the streaming Call RPC method

func (*GRPCServer) HTTPHandler

func (s *GRPCServer) HTTPHandler() func(w http.ResponseWriter, r *http.Request)

HTTPHandler provides a simple HTTP endpoint for testing

func (*GRPCServer) ListFunctions

ListFunctions implements the ListFunctions RPC method

type Registry

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

Registry holds all discovered server functions

func GetGlobalRegistry

func GetGlobalRegistry() *Registry

GetGlobalRegistry returns the global registry with all registered functions

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new function registry

func (*Registry) BuildAndImportServerPackages

func (r *Registry) BuildAndImportServerPackages(serverDir string) error

BuildAndImportServerPackages dynamically builds and imports server packages to trigger their init() functions and register their functions

func (*Registry) CallFunction

func (r *Registry) CallFunction(ctx context.Context, serviceName, functionName string, args []*anypb.Any) (*anypb.Any, error)

CallFunction calls a registered function with the given arguments

func (*Registry) DiscoverFunctions

func (r *Registry) DiscoverFunctions(serverDir string) error

DiscoverFunctions automatically discovers functions from source files

func (*Registry) GetFunction

func (r *Registry) GetFunction(serviceName, functionName string) (*FunctionMeta, bool)

GetFunction returns metadata for a specific function

func (*Registry) ListFunctions

func (r *Registry) ListFunctions(serviceName string) []*pb.FunctionInfo

ListFunctions returns all registered functions

func (*Registry) RegisterFromGlobal

func (r *Registry) RegisterFromGlobal() error

RegisterFromGlobal copies all functions from the global registry to this registry

func (*Registry) RegisterFunction

func (r *Registry) RegisterFunction(serviceName, functionName string, fn interface{}) error

RegisterFunction registers a single function

func (*Registry) RegisterPackage

func (r *Registry) RegisterPackage(packageName string, pkg interface{}) error

RegisterPackage registers all exported functions from a package

Jump to

Keyboard shortcuts

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