Client: Client
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)
- url string
The server URL
- config *ClientConfiguration
- The client endpoint configurations
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)
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
executeServerStreaming
function executeServerStreaming(string methodID, anydata payload, map<string | string[ ]> headers) returns [stream<anydata, Error?>, map<string | string[ ]>] | Error
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
executeClientStreaming
function executeClientStreaming(string methodID, map<string | string[ ]> headers) returns StreamingClient | Error
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
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
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
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?
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
- clientEndpoint AbstractClientEndpoint
Client endpoint
- descriptorKey string
Key of the proto descriptor
- descriptorMap map<any>
Proto descriptor map with all the dependent descriptors