The documentation you are viewing is for Dapr v1.5 which is an older version of Dapr. For up-to-date documentation, see the latest version.
操作方法:将 Dapr 配置为使用 gRPC
如何配置 Dapr 以使用gRPC实现低延迟、高性能的场景
Dapr 为本地调用实现 HTTP 和 gRPC API 。 gRPC 适用于低延迟、高性能的场景,并且使用原生客户端进行语言集成。
您可以在这里找到自动生成的客户端列表。
Dapr 运行时实现 proto 服务 ,应用程序可以通过 gRPC 进行通信。
除了通过 gRPC 调用 Dapr , Dapr 也可以通过 gRPC 与应用程序通信。 要做到这一点,应用程序需要托管 gRPC 服务器,并实现 Dapr appcallback 服务。
配置 Dapr 以通过 gRPC 与应用通信
自托管
在自托管模式下运行时,使用 --app-protocol
标志来配置 Dapr 使用 gRPC 与应用程序通信:
dapr run --app-protocol grpc --app-port 5005 node app.js
这告诉 Dapr 在端口5005
上通过 gRPC 与应用进行通信。
Kubernetes
在 Kubernetes 上,在 deployment YAML 中设置以下注解:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: default
labels:
app: myapp
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "myapp"
dapr.io/app-protocol: "grpc"
dapr.io/app-port: "5005"
...
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.