Menu
Open source
Client.invoke(url, request [,params])
Invokes an unary RPC request to the given method.
The given method to invoke must have its RPC schema previously loaded via the Client.load() function, otherwise an error will be thrown.
Client.connect() must be called first before invoking a request, otherwise an error will be thrown.
Parameter | Type | Description |
---|---|---|
url | string | The gRPC method url to invoke, in the form /package.Service/Method , e.g. /google.cloud.language.v1.LanguageService/AnalyzeSentiment . The leading slash / is optional. |
request | object | The canonical request object, as-per the Protobuf JSON Mapping. |
params (optional) | object | Params object containing additional request parameters. |
Returns
Type | Description |
---|---|
Response | gRPC Response object. |
Examples
JavaScript
import grpc from 'k6/net/grpc';
import { check } from 'k6';
const client = new grpc.Client();
client.load([], 'routeguide.proto');
export default () => {
client.connect('localhost:10000', { plaintext: true });
const response = client.invoke('main.RouteGuide/GetFeature', {
latitude: 410248224,
longitude: -747127767,
});
check(response, { 'status is OK': (r) => r && r.status === grpc.StatusOK });
console.log(response.message.name);
// output: 3 Hasta Way, Newton, NJ 07860, USA
client.close();
};
Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video
Performance testing and observability in Grafana Cloud
In this webinar, learn how Grafana Cloud k6 offers you the best developer experience for performance testing.
User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.