module
0.0.0-20240708230752-24d8fef1f56e
Repository: https://github.com/yaron2/dapr-grpc-go.git
Documentation: pkg.go.dev
# README
gRPC proxy example with Dapr and Go
This example shows how to use Dapr gRPC proxying with Go using native gRPC clients and servers.
Getting started
Prerequisites:
Install Dapr
If you haven't already run dapr init
, do so via your terminal:
$ dapr init
Run the gRPC Go server
cd greeter_server
go mod tidy
dapr run --app-id server --dapr-grpc-port 50006 --app-port 50051 -- go run main.go
Run the gRPC Go client
cd greeter_client
go mod tidy
dapr run --app-id client --dapr-grpc-port 50001 -- go run main.go
Verify it works
If everything is set up correctly, you should see an output similar to this:
== APP == 2022/11/21 16:12:07 Greeting: Hello 0, 20221121161207
== APP == 2022/11/21 16:12:08 Greeting: Hello 1, 20221121161208
== APP == 2022/11/21 16:12:09 Greeting: Hello 2, 20221121161209
== APP == 2022/11/21 16:12:10 Greeting: Hello 3, 20221121161210
== APP == 2022/11/21 16:12:11 Greeting: Hello 4, 20221121161211
== APP == 2022/11/21 16:12:12 Greeting: Hello 5, 20221121161212
== APP == 2022/11/21 16:12:13 Greeting: Hello 6, 20221121161213
== APP == 2022/11/21 16:12:14 Greeting: Hello 7, 20221121161214
== APP == 2022/11/21 16:12:15 Greeting: Hello 8, 20221121161215
== APP == 2022/11/21 16:12:16 Greeting: Hello 9, 20221121161216
Running on Kubernetes
Running this example on Kubernetes is the same as running it locally. You simply need to Dockerize your code and assign the dapr.io/app-id
value to client
and server
on your deployments.
Deploy the server
cd greeter_server
kubectl apply -f deploy.yaml
Wait until the server is running with 2/2 containers.
Deploy the client
cd greeter_client
kubectl apply -f deploy.yaml
Observe the calls
kubectl logs -l app=server -c server -f
# Packages
No description provided by the author