This example demonstrates gRPC server and client functionality.
- gRPC Server with reflection enabled
- gRPC Client for calling external services
- Proto file configuration
- TLS/mTLS support (commented examples)
- Data enrichment from external gRPC services
config.hcl- Complete configuration with server, client, and flows
# Start the service
mycel start --config ./examples/grpc
# Test with grpcurl (requires reflection enabled)
grpcurl -plaintext localhost:50051 list
grpcurl -plaintext localhost:50051 UserService/ListUsers
grpcurl -plaintext -d '{"id": "1"}' localhost:50051 UserService/GetUserconnector "grpc_api" {
type = "grpc"
driver = "server"
port = 50051
proto_path = "./protos"
reflection = true
}connector "user_service" {
type = "grpc"
driver = "client"
target = "user-service:50051"
proto_path = "./protos"
insecure = true
}Operations use the format ServiceName/MethodName:
flow "get_user" {
from {
connector = "grpc_api"
operation = "UserService/GetUser"
}
# ...
}mycel start --config ./examples/grpcYou should see:
INFO Starting service: grpc-example
INFO Loaded 2 connectors: grpc_api, database
INFO gRPC server listening on :50051
INFO gRPC reflection enabled
grpcurl -plaintext localhost:50051 listExpected output:
UserService
grpc.reflection.v1alpha.ServerReflection
grpcurl -plaintext localhost:50051 describe UserServiceExpected output:
UserService is a service:
service UserService {
rpc CreateUser ( CreateUserRequest ) returns ( User );
rpc GetUser ( GetUserRequest ) returns ( User );
rpc ListUsers ( Empty ) returns ( UserList );
}
grpcurl -plaintext localhost:50051 UserService/ListUsersExpected output:
{
"users": []
}grpcurl -plaintext -d '{"email": "test@example.com", "name": "Test User"}' \
localhost:50051 UserService/CreateUserExpected output:
{
"id": "<uuid>",
"email": "test@example.com",
"name": "Test User"
}INFO gRPC request: UserService/ListUsers
INFO Flow: list_users → database:users
INFO gRPC response sent in 2ms
"grpcurl: command not found"
Install grpcurl:
# macOS
brew install grpcurl
# Linux
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest"Failed to dial: connection refused"
The gRPC server is not running. Check if port 50051 is in use:
lsof -i :50051"Server does not support reflection"
Ensure reflection = true is set in the gRPC connector config.
"Proto file not found"
Check that proto_path points to a valid directory with .proto files.
- TCP Example - Alternative to gRPC for simpler protocols