Client: Client

Isolated

The base client used in the generated client code to provide the capability for initiating the contact and executing remote calls with a remote gRPC service.

Constructor

Gets invoked to initialize the endpoint. During the initialization, the configurations provided through the config record are used for the endpoint initialization.

1HelloWorldClient helloWorldClient = check new("http://localhost:9091");
init (string url, *ClientConfiguration config)

Remote Methods

executeSimpleRPC

Calls when executing a unary gRPC service.

executeServerStreaming

Calls when executing a server streaming call with a gRPC service.

executeClientStreaming

Calls when executing a client streaming call with a gRPC service.

executeBidirectionalStreaming

Calls when executing a bi-directional streaming call with a gRPC service.

Methods

initStub

Calls when initializing the client endpoint with the service descriptor data extracted from the proto file.

executeSimpleRPC

function executeSimpleRPC(string methodID, anydata payload, map<string | string[ ]> headers) returns ([anydata, map<string | string[ ]>] | Error)
Isolated Function
Remote Function

Calls when executing a unary gRPC service.

1[anydata, map<string|string[]>]|grpc:Error result = grpcClient->executeSimpleRPC("HelloWorld/hello", req, headers);

Parameters

  • methodID string
  • Remote service method ID

  • payload anydata
  • Request message. The message type varies with the remote service method parameter

  • headers map<string | string[ ]> (default {})
  • Optional headers parameter. The header value are passed only if needed. The default value is ()

Return Type

(([anydata, map<string | string[ ]>] | Error))

The response as an anydata type value or else a grpc:Error

executeServerStreaming

function executeServerStreaming(string methodID, anydata payload, map<string | string[ ]> headers) returns [stream<anydata, Error?>, map<string | string[ ]>] | Error
Isolated Function
Remote Function

Calls when executing a server streaming call with a gRPC service.

1[stream<anydata, grpc:Error?>, map<string|string[]>]|grpc:Error result = grpcClient->executeServerStreaming("HelloWorld/hello", req, headers);

Parameters

  • methodID string
  • Remote service method ID

  • payload anydata
  • Request message. The message type varies with the remote service method parameter

  • headers map<string | string[ ]> (default {})
  • Optional headers parameter. The header value are passed only if needed. The default value is ()

Return Type

([stream<anydata, Error?>, map<string | string[ ]>] | Error)

A stream<anydata, grpc:Error?> or a grpc:Error when an error occurs while sending the request

executeClientStreaming

function executeClientStreaming(string methodID, map<string | string[ ]> headers) returns StreamingClient | Error
Isolated Function
Remote Function

Calls when executing a client streaming call with a gRPC service.

1grpc:StreamingClient|grpc:Error result = grpcClient->executeClientStreaming("HelloWorld/hello", headers);

Parameters

  • methodID string
  • Remote service method ID

  • headers map<string | string[ ]> (default {})
  • Optional headers parameter. The header value are passed only if needed. The default value is ()

Return Type

(StreamingClient | Error)

A grpc:StreamingClient object or a grpc:Error when an error occurs

executeBidirectionalStreaming

function executeBidirectionalStreaming(string methodID, map<string | string[ ]> headers) returns StreamingClient | Error
Isolated Function
Remote Function

Calls when executing a bi-directional streaming call with a gRPC service.

1grpc:StreamingClient|grpc:Error result = grpcClient->executeBidirectionalStreaming("HelloWorld/hello", headers);

Parameters

  • methodID string
  • Remote service method ID

  • headers map<string | string[ ]> (default {})
  • Optional headers parameter. The header value are passed only if needed. The default value is ()

Return Type

(StreamingClient | Error)

A grpc:StreamingClient object or a grpc:Error when an error occurs

initStub

function initStub(AbstractClientEndpoint clientEndpoint, string descriptorKey, map<any> descriptorMap) returns Error?
Isolated Function

Calls when initializing the client endpoint with the service descriptor data extracted from the proto file.

1grpc:Error? result = grpcClient.initStub(self, ROOT_DESCRIPTOR, getDescriptorMap());

Parameters

  • descriptorKey string
  • Key of the proto descriptor

  • descriptorMap map<any>
  • Proto descriptor map with all the dependent descriptors

Return Type

(Error?)

A grpc:Error if an error occurs while initializing the stub or else ()