gRPC Client
调用 gRPC 服务方法。
调用 gRPC 服务的一个一元方法,服务由编排器可访问的 .proto 文件描述,主机和 proto 设置取自凭据。
工作原理
- 解析配置。
connection_id、service和method缺失时回退到输入 payload 中的同名键。 - 构建请求消息:配置的
payload为非空对象时使用它;否则使用输入数据中的payload.payload,或整个输入数据。 - 解析凭据配置:
host(host:port)、protoPath(编排器文件系统上的文件)、可选的packageName和secure。 - 加载 proto(保留字段原始名称,long 和 enum 转为字符串,并填充默认值),依次查找
packageName与service;secure为 true 时建立 TLS 通道,否则建立明文通道。 - 以该消息调用
method;若密钥含token,则附带元数据Authorization: Bearer <token>。响应以{ response }从out输出。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-confirm-order",
"label": "Confirm order",
"operator_slug": "io.grpc",
"operator_version": "1.0.0",
"config": {
"connection_id": "pi-credential-xxxx",
"service": "OrderService",
"method": "ConfirmOrder",
"payload": {
"order_id": "{{ $json.order_id }}"
}
}
}{
"ok": true,
"data": {
"response": {
"order_id": "ord_123",
"status": "CONFIRMED",
"total_cents": "25000"
}
},
"port": "out"
}配置
-
connection_idstring 必填 -
gRPC 端点的凭据。接受 `certificate`(用于 mTLS 的 TLS 证书 + 密钥)或 `object`(主机 + .proto 路径 + 高级配置)类型的凭据。
-
servicestring 必填 -
服务名称
-
methodstring 必填 -
方法名称
-
payloadobject 可选 -
请求消息
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
connection_id - 凭据配置须包含
host、protoPath、可选的packageName和secure;密钥中只读取token。选择器接受certificate凭据,但不会使用客户端证书:TLS 使用系统信任库且不带客户端证书(不支持 mTLS)。 -
payload - 请求消息。空对象视为未设置,此时改为发送输入数据。
输出端口
out 默认 方法返回了响应。response 为解码后的响应消息。
数据
{
"response": {
"order_id": "ord_123",
"status": "CONFIRMED",
"total_cents": "25000"
}
}error 调用返回 gRPC 状态错误(数据为 { error, code },含数字 gRPC 状态码),或准备阶段失败(数据为 { error })。
数据
{
"error": "14 UNAVAILABLE: No connection established",
"code": 14
}在表达式中
后续节点可通过 $("gRPC Client").item.json.<路径> 读取此节点输出中的内容(请把 gRPC Client 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("gRPC Client").item.json.responsegRPC 响应消息 | ||
$("gRPC Client").item.json.response.order_id | — | |
$("gRPC Client").item.json.response.status | — | |
$("gRPC Client").item.json.response.total_cents | — |
— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
protoPath missing in connection config | error | 凭据配置中缺少 protoPath。请添加编排器主机上存在的 .proto 文件路径。 |
Package <packageName> not found in proto | error | packageName 与 proto 的顶层包不匹配。只查找单段名称(例如 helloworld,而非 acme.orders)。 |
Service <service> not found | error | 所选包中未定义 service。 |
Method <method> not found | error | method 不是该服务的方法。请使用 proto 中的原始名称。 |
connection_id is required | error | 未选择凭据。 |
输入契约
-
connection_idstring 必填 -
servicestring 必填 -
methodstring 必填 -
payloadobject 可选
输出契约
-
responseobject 可选 -
gRPC 响应消息
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "io.grpc",
"name": "gRPC Client",
"category": "io",
"version": "1.0.0",
"description": "Call gRPC Service method.",
"capabilities": [
"grpc",
"microservices",
"protobuf"
],
"config_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "gRPC Credential",
"description": "Credential for the gRPC endpoint. Accepts credentials of type `certificate` (TLS cert + key for mTLS) or `object` (host + .proto path + advanced config).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"certificate",
"object"
],
"types": [
"grpc"
]
}
},
"service": {
"type": "string",
"description": "Service Name"
},
"method": {
"type": "string",
"description": "Method Name"
},
"payload": {
"type": "object",
"description": "Request Message"
}
},
"required": [
"connection_id",
"service",
"method"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"service": {
"type": "string"
},
"method": {
"type": "string"
},
"payload": {
"type": "object"
}
},
"required": [
"connection_id",
"service",
"method"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"response": {
"type": "object",
"description": "gRPC Response Message"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Response",
"description": "gRPC Response Message",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "gRPC Error Code",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"standard-io",
"microservices"
],
"tags": [
"grpc",
"rpc"
],
"is_stateful": false,
"publisher": {
"identity": "org_link_loom",
"profile": {
"name": "Link Loom",
"verified": true,
"url": "https://me.veripass.com/link-loom",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "gRPC Credential",
"description": "Credential for the gRPC endpoint. Accepts credentials of type `certificate` (TLS cert + key for mTLS) or `object` (host + .proto path + advanced config).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"certificate",
"object"
],
"types": [
"grpc"
]
}
},
"service": {
"type": "string",
"description": "Service Name"
},
"method": {
"type": "string",
"description": "Method Name"
},
"payload": {
"type": "object",
"description": "Request Message"
}
},
"required": [
"connection_id",
"service",
"method"
]
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"service": {
"type": "string"
},
"method": {
"type": "string"
},
"payload": {
"type": "object"
}
},
"required": [
"connection_id",
"service",
"method"
]
}{
"type": "object",
"properties": {
"response": {
"type": "object",
"description": "gRPC Response Message"
}
}
}[
{
"port_id": "out",
"label": "Response",
"description": "gRPC Response Message",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "gRPC Error Code",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 凭据
- 在服务器端根据
connection_id解析,密钥不会进入工作流。 - 能力
grpcmicroservicesprotobuf- 标签
grpcrpc
说明与限制
- 仅支持一元调用,不处理流式方法。调用未设置截止时间,也不会重试。
.proto文件在每次运行时从编排器文件系统读取,不会随工作流上传。response中的 64 位整数和枚举以字符串形式返回。
已对照编排器代码核实 · 31e874b · 2026-11-26