gRPC
Know the component and how to use it.
The gRPC component enables calls to gRPC service of the unary and client stream type via payload or via file.
Take a look at the configuration parameters of the component:
- Authenticate with client certificates: when its activated, it can select client authentication with client certificates (mTLS). Use the Certificate Chain account type.
- Authenticate with Google Key: when its activated, it can select client authentication with Google Key. Use the Google Key account type.
- Method Type: type of method to be used in the service invocation. The supported method types are Unary, Client Stream - via Payload and Client Stream - via File. This parameter doesn’t support Double Braces.
- URL: call address of the gRPC service. Eg: localhost:50051. This parameter doesn’t support Double Braces.
- Headers: configures all the types of necessary headers for the call (eg.: Authorization: Bearer Co4ECg1FeGFtcGxlLnByb3RvIjwKDEh).
- Custom Accounts: set the custom account label to be used in Double Braces expressions.
- Service name: name of the service described inside the configuration file .proto of the gRPC server. This parameter doesn’t support Double Braces. In the example below, Service Name will be “Greeter”:
service Greeter {
rpc helloMethod(Hellorequest) returns (HelloResponse);
}
- Method Name: name of the method to be described inside the configuration file .proto of the gRPC server. This parameter doesn’t support Double Braces. In the example below, Method Name wil be “helloMethod”:
service Greeter {
rpc helloMethod(Hellorequest) returns (HelloResponse);
}
- Proto Descriptor File: base64 of the “Descriptor” file from the .proto file. This parameter doesn’t support Double Braces. Firstly, “Descriptor” must be generated from a .proto file. To make it, just run the following command in the current directory that is being located in the .proto file:
.proto file of the directory: Example.proto
Name of the descriptor file to be generated: proto.desc
protoc --include_imports --descriptor_set_out=proto.desc Example.proto
tLmRpZ2liZWUuZ3JwY0IMRGlnaWJlZVByb3RvUAGiAgNITFdiBnByb3RvMw==
- Payload: the request payload to be sent to the gRPC server. For the Unary method type, a simple object that has the fields defined in the .proto file must be used. For the Client Stream - via Payload type method an object array, in which each array item is a message to be sent to the gRPC server must be used. This parameter accepts Double Braces.
- File Name: name of the file used to send the payload data in Client Stream - via File mode. This file must be a JSON file that has received an array. This array must contain the messages to be sent asynchronously to the gRPC server (stream).
- JSON Path: JSON Path expression that determines how the JSON file in the stream is read. Only for the Client Stream - via File mode.
- Connect Timeout: expiration time of the connection with the server (in milliseconds).
- Request Timeout: expiration time of the component request call with the gRPC server (in milliseconds).
- Fail On Error: if the option is enabled, the execution of the pipeline with error will be interrupted; otherwise, the pipeline execution proceeds, but the result will show a false value for the “success” property.
IMPORTANT: some of the parameters above support Double Braces. To understand how this language works, read our article by clicking here.
An input payload to be used inside the component payload parameter is expected.
When executing a SFTP component using the download, upload or move operations, the following JSON structure will be generated:
{
"response": {},
"success": "true"
}
- response: response JSON received from the gRPC service
- success: "true" if there’s a connection and the script is execution even without returning errors in stderr
{
"success": false,
"message": "Something went wrong while trying to call the gRPC server",
"error": "java.net.SocketTimeoutException: connect timed out"
}
- success: “false” when the operation fails
- message: message about the error
- exception: information about the type of occured error
Given the .proto file example:
Example.proto
syntax = "proto3";
package digibee;
service Greeter {
rpc unary (HelloRequest) returns (HelloReply) {}
rpc clientStream (stream HelloRequest) returns (HelloReply) {}
rpc serverStream (HelloRequest) returns (stream HelloReply) {}
rpc Bidi(stream HelloRequest) returns (stream HelloReply);
}
message HelloRequest {
string name = 1;
string address = 2;
}
message HelloReply {
string message = 1;
int32 status = 2;
}
Firstly, it’s necessary to generate the “descriptor” file:
1. Inside the file directory, execute the command:
protoc --include_imports --descriptor_set_out=proto.desc Example.proto
2. With the “descriptor” at hand, generate the base64 of the proto.desc file and add it in the Proto Descriptor File field.
Component configurations:
Method Type: Unary
URL: localhost:50051
Service Name: Greeter
Method Name: unary
Proto Descriptor File: <BASE64 OF THE DESCRIPTOR FILE GENERATE ABOVE>
Payload:
{
"name": "Charles",
"address": "390 Fifth Avenue"
}
Connect Timeout: 30000
Request Timeout: 30000
Fail On Error: disabled
Response
{
"message": "Hi Charles",
"status": 200
}
Given the .proto file:
Example.proto
syntax = "proto3";
package digibee;
service Greeter {
rpc unary (HelloRequest) returns (HelloReply) {}
rpc clientStream (stream HelloRequest) returns (HelloReply) {}
rpc serverStream (HelloRequest) returns (stream HelloReply) {}
rpc Bidi(stream HelloRequest) returns (stream HelloReply);
}
message HelloRequest {
string name = 1;
string address = 2;
}
message HelloReply {
string message = 1;
int32 status = 2;
}
Firstly, it’s necessary to generate the “descriptor” file:
1. Inside the file directory, execute the command:
protoc --include_imports --descriptor_set_out=proto.desc Example.proto
2. With the “descriptor” at hand, generate the base64 of the proto.desc file and add it in the Proto Descriptor File field.
Component configurations:
Method Type: Client Stream - via Payload
URL: localhost:50051
Service Name: Greeter
Method Name: clientStream
Proto Descriptor File: <BASE64 OF THE DESCRIPTOR FILE GENERATED ABOVE>
Payload:
[
{
"name": "Charles",
"address": "390 Fifth Avenue"
},
{
"name": "Paul",
"address": "32 Seventh Avenue"
},
{
"name": "Yan",
"address": "12 Fourth Avenue"
}
]
Connect Timeout: 30000
Request Timeout: 30000
Fail On Error: disabled
Response
{
"message": "Hi Charles, Paul and Yan",
"status": 200
}
Given the following .proto file:
Example.proto
syntax = "proto3";
package digibee;
service Greeter {
rpc unary (HelloRequest) returns (HelloReply) {}
rpc clientStream (stream HelloRequest) returns (HelloReply) {}
rpc serverStream (HelloRequest) returns (stream HelloReply) {}
rpc Bidi(stream HelloRequest) returns (stream HelloReply);
}
message HelloRequest {
string name = 1;
string address = 2;
}
message HelloReply {
string message = 1;
int32 status = 2;
}
Firstly, it’s necessary to generate the “descriptor” file:
1. Inside the file directory, execute the command:
protoc --include_imports --descriptor_set_out=proto.desc Example.proto
2. With the “descriptor” at hand, generate the base64 of the proto.desc file and add it in the Proto Descriptor File field.
Component configurations:
Method Type: Client Stream - via Payload
URL: localhost:50051
Service Name: Greeter
Method Name: clientStream
Proto Descriptor File: <BASE64 OF THE DESCRIPTOR FILE GENERATED ABOVE>
File Name: file.json
file.json
{
"infos": [
{
"name": "Charles",
"address": "390 Fifth Avenue"
},
{
"name": "Paul",
"address": "32 Seventh Avenue"
},
{
"name": "Yan",
"address": "12 Fourth Avenue"
}
]
}
JSON Path: $.infos[*]
Connect Timeout: 30000
Request Timeout: 30000
Fail On Error: disabled
Response
{
"message": "Hi Charles, Paul and Yan",
"status": 200
}
Last modified 2mo ago