examples/grpc-interop/README.md
This example shows that any standard gRPC client can call a go-micro service — no go-micro SDK required on the client side.
The server is a normal go-micro service using the gRPC transport. The client is a plain google.golang.org/grpc client with no go-micro imports.
go-micro's gRPC server uses a grpc.UnknownServiceHandler that catches all incoming requests and routes them by parsing the standard gRPC method path (/package.Service/Method). This means any language with gRPC support (Python, Java, Rust, etc.) can call go-micro services using generated protobuf stubs.
Start the server:
cd examples/grpc-interop
go run ./server/
In another terminal, call it with the standard gRPC client:
cd examples/grpc-interop
go run ./client/ --name Alice
# Response: Hello Alice
Generate stubs from proto/greeter.proto in your language of choice and point them at localhost:50051. For example, with Python:
pip install grpcio-tools
python -m grpc_tools.protoc -Iproto --python_out=. --grpc_python_out=. proto/greeter.proto
import grpc
import greeter_pb2
import greeter_pb2_grpc
channel = grpc.insecure_channel("localhost:50051")
stub = greeter_pb2_grpc.GreeterStub(channel)
response = stub.Hello(greeter_pb2.HelloRequest(name="Alice"))
print(response.message) # Hello Alice
pb.RegisterGreeterHandler()protoc-gen-go-grpc.proto file — that's the contractprotoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
--micro_out=. --micro_opt=paths=source_relative \
proto/greeter.proto
Requires protoc-gen-go, protoc-gen-go-grpc, and protoc-gen-micro.