Function Registration#
Registering Functions in Flowkit
In Flowkit, functions are modular units of logic that must be registered before they can be called over GRPC. Each function is stored in a shared registry with a unique name and optional metadata.
How it works:
Functions are registered at startup using flowkit.RegisterFunction(…)
Each function has a name, description, and implementation logic
Optionally, a function can support streaming results
The function must follow this signature:
func(ctx context.Context, req *Request) (*Response, error)
Example registration:
flowkit.RegisterFunction("add", &Function{
Name: "add",
Description: "Adds two integers",
Run: func(ctx context.Context, req *Request) (*Response, error) {
// Implementation here...
},
})
To register a streaming function:
flowkit.RegisterFunction("streamLogs", &Function{
Name: "streamLogs",
Stream: true,
Description: "Streams log output line by line",
RunStream: func(ctx context.Context, req *Request, stream ServerStream) error {
// Stream logic...
},
})