Documentation
¶
Index ¶
- func CreateGRPCServer(registry *Registry) *grpc.Server
- func GetModuleName() (string, error)
- func RegisterGlobalFunction(serviceName, functionName string, fn interface{}) error
- type FunctionMeta
- type GRPCServer
- func (s *GRPCServer) Call(ctx context.Context, req *pb.FunctionRequest) (*pb.FunctionResponse, error)
- func (s *GRPCServer) CallStream(req *pb.FunctionRequest, stream pb.FunctionService_CallStreamServer) error
- func (s *GRPCServer) HTTPHandler() func(w http.ResponseWriter, r *http.Request)
- func (s *GRPCServer) ListFunctions(ctx context.Context, req *pb.ListFunctionsRequest) (*pb.ListFunctionsResponse, error)
- type Registry
- func (r *Registry) BuildAndImportServerPackages(serverDir string) error
- func (r *Registry) CallFunction(ctx context.Context, serviceName, functionName string, args []*anypb.Any) (*anypb.Any, error)
- func (r *Registry) DiscoverFunctions(serverDir string) error
- func (r *Registry) GetFunction(serviceName, functionName string) (*FunctionMeta, bool)
- func (r *Registry) ListFunctions(serviceName string) []*pb.FunctionInfo
- func (r *Registry) RegisterFromGlobal() error
- func (r *Registry) RegisterFunction(serviceName, functionName string, fn interface{}) error
- func (r *Registry) RegisterPackage(packageName string, pkg interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateGRPCServer ¶
CreateGRPCServer creates and configures a gRPC server
func GetModuleName ¶
GetModuleName reads the module name from go.mod
func RegisterGlobalFunction ¶
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 ¶
func (s *GRPCServer) Call(ctx context.Context, req *pb.FunctionRequest) (*pb.FunctionResponse, error)
Call implements the Call RPC method
func (*GRPCServer) CallStream ¶
func (s *GRPCServer) CallStream(req *pb.FunctionRequest, stream pb.FunctionService_CallStreamServer) error
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 ¶
func (s *GRPCServer) ListFunctions(ctx context.Context, req *pb.ListFunctionsRequest) (*pb.ListFunctionsResponse, error)
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 (*Registry) BuildAndImportServerPackages ¶
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 ¶
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 ¶
RegisterFromGlobal copies all functions from the global registry to this registry
func (*Registry) RegisterFunction ¶
RegisterFunction registers a single function
func (*Registry) RegisterPackage ¶
RegisterPackage registers all exported functions from a package