Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Open source

Constants

Define constants to distinguish between gRPC Response statuses.

ConstantDescription
StatusOKOK is returned on success.
StatusCanceledCanceled indicates the operation was canceled (typically by the caller).
StatusUnknownUnknown error.
StatusInvalidArgumentInvalidArgument indicates the client specified an invalid argument.
StatusDeadlineExceededDeadlineExceeded means operation expired before completion.
StatusNotFoundNotFound means some requested entity (e.g., file or directory) was not found.
StatusAlreadyExistsAlreadyExists means an attempt to create an entity failed because one already exists.
StatusPermissionDeniedPermissionDenied indicates the caller does not have permission to execute the specified operation.
StatusResourceExhaustedResourceExhausted indicates some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.
StatusFailedPreconditionFailedPrecondition indicates operation was rejected because the system is not in a state required for the operation’s execution.
StatusAbortedAborted indicates the operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc.
StatusOutOfRangeOutOfRange means operation was attempted past the valid range. E.g., seeking or reading past end of file.
StatusUnimplementedUnimplemented indicates operation is not implemented or not supported/enabled in this service.
StatusInternalInternal errors. Means some invariants expected by the underlying system have been broken.
StatusUnavailableUnavailable indicates the service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent operations.
StatusDataLossDataLoss indicates unrecoverable data loss or corruption.
StatusUnauthenticatedUnauthenticated indicates the request does not have valid authentication credentials for the operation.

Example

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

const client = new grpc.Client();
client.load(['definitions'], 'hello.proto');

export default () => {
  client.connect('grpcbin.test.k6.io:9001', {
    // plaintext: false
  });

  const data = { greeting: 'Bert' };
  const response = client.invoke('hello.HelloService/SayHello', data);

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

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