gRPC

Discover more about the gRPC component and how to use it on the Digibee Integration Platform.

gRPC enables calls to gRPC service of the unary and client stream type via payload or via file.

Parameters

Take a look at the configuration options for the component. Parameters supported by Double Braces expressions are marked with (DB).

ParameterDescriptionDefault valueData type

Authenticate with client certificates

When it's activated, it can select client authentication with client certificates (mTLS). Use the Certificate Chain account type.

False

Boolean

Authenticate with Google Key

When it's activated, it can select client authentication with Google Key. Use the Google Key account type.

False

Boolean

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.

Unary

String

URL

Call address of the gRPC service, for example: localhost:50051.

N/A

String

Headers (DB)

Configures all the types of necessary headers for the call (for example: Authorization: Bearer Co4ECg1FeGFtcGxlLnByb3RvIjwKDEh).

N/A

Key-value pair

Custom Accounts

Set the custom account label to be used in Double Braces expressions.

N/A

String

Service Name

Name of the service described inside the configuration file .proto of the gRPC server. Learn more in Parameters additional information.

N/A

String

Method Name

Name of the method to be described inside the configuration file .proto of the gRPC server. Learn more in Parameters additional information.

N/A

String

Proto Descriptor File

Base64 of the “Descriptor” file from the .proto file. Learn more in Parameters additional information.

N/A

String (Base64)

Payload (DB)

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.

N/A

JSON Object or Array

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).

N/A

String

JSON Path

JSON Path expression that determines how the JSON file in the stream is read. Only for the Client Stream - via File mode.

N/A

String

Connect Timeout

Expiration time of the connection with the server (in milliseconds).

30000

Integer

Request Timeout

Expiration time of the component request call with the gRPC server (in milliseconds).

30000

Integer

Fail On Error

If the option is activated, the execution of the pipeline with an error will be interrupted; otherwise, the pipeline execution proceeds, but the result will show a false value for the “success” property.

False

Boolean

Parameters additional information

Service Name

See an example of Service Name as “Greeter”:

service Greeter {
  rpc helloMethod(Hellorequest) returns (HelloResponse);

}

Method Name

See an example of Method Name as “helloMethod”:

service Greeter {
  rpc helloMethod(Hellorequest) returns (HelloResponse);

}

Proto Descriptor File

To use this parameter, the “descriptor” must first be created from a .proto file. To create it, please follow the steps below:

  1. Create the descriptor file by executing the following commands in the current directory located in the .proto file:

  • .proto file of the directory: Example.proto

  • Name of the descriptor file to be created: proto.desc

protoc --include_imports --descriptor_set_out=proto.desc Example.proto

You can download the protoc compiler at Protocol Buffer Compiler Installation.

  1. Encode this file to base64:

tLmRpZ2liZWUuZ3JwY0IMRGlnaWJlZVByb3RvUAGiAgNITFdiBnByb3RvMw==
  1. Inform this base64 in the Proto Descriptor File property.

Messages flow

Input

An input payload to be used inside the component Payload parameter is expected.

Output

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 executed even without returning errors in stderr.

Output with error

{
"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 occurred error.

To better understand the message flow in the Platform, read the documentation on Message processing.

gRPC component in action

Unary

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
  1. 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
}

Client Stream - via Payload

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
  1. 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
}

Client Stream - via File

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
  1. 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 updated