Menu

This is documentation for the next version of K6. For the latest stable release, go to the latest version.

Open source

Response

NameTypeDescription
Response.statusnumberThe response gRPC status code. Use the gRPC status constants to check equality.
Response.messageobjectThe successful protobuf message, serialized to JSON. Will be null if status !== grpc.StatusOK.
Response.headersobjectKey-value pairs representing all the metadata headers returned by the gRPC server.
Response.trailersobjectKey-value pairs representing all the metadata trailers returned by the gRPC server.
Response.errorobjectIf status !== grpc.StatusOK then the error protobuf message, serialized to JSON; otherwise null.

Example

JavaScript
import grpc from 'k6/net/grpc';
import { check, sleep } from 'k6';

const client = new grpc.Client();
client.load(null, 'quickpizza.proto');

export default () => {
  client.connect('grpc-quickpizza.grafana.com:443', {
    // plaintext: false
  });

  const data = { ingredients: ['Cheese'], dough: 'Thick' };
  const response = client.invoke('quickpizza.GRPC/RatePizza', data);

  check(response, {
    'status is OK': (r) => r && r.status === grpc.StatusOK,
  });

  client.close();
  sleep(1);
};