How to use the @grpc/grpc-js.status.UNIMPLEMENTED function in @grpc/grpc-js

To help you get started, we’ve selected a few @grpc/grpc-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LN-Zap / node-lnd-grpc / src / grpc.js View on Github external
// This is a way of probing the api to determine it's state.
      await this.services.WalletUnlocker.unlockWallet({}, { deadline: getDeadline(PROBE_TIMEOUT) })
    } catch (error) {
      switch (error.code) {
        /*
          `UNIMPLEMENTED` indicates that the requested operation is not implemented or not supported/enabled in the
           service. This implies that the wallet is already unlocked, since the WalletUnlocker service is not active.
           See

           `DEADLINE_EXCEEDED` indicates that the deadline expired before the operation could complete. In the case of
           our probe here the likely cause of this is that we are connecting to an lnd node where the `noseedbackup`
           flag has been set and therefore the `WalletUnlocker` interace is non-functional.

           https://github.com/grpc/grpc-node/blob/master/packages/grpc-native-core/src/constants.js#L129.
         */
        case status.UNIMPLEMENTED:
        case status.DEADLINE_EXCEEDED:
          debug('Determined wallet state as:', WALLET_STATE_ACTIVE)
          walletState = WALLET_STATE_ACTIVE
          return walletState

        /**
          `UNKNOWN` indicates that unlockWallet was called without an argument which is invalid.
          This implies that the wallet is waiting to be unlocked.
        */
        case status.UNKNOWN:
          debug('Determined wallet state as:', WALLET_STATE_LOCKED)
          walletState = WALLET_STATE_LOCKED
          return walletState

        /**
          Bubble all other errors back to the caller and abort the connection attempt.
github googleapis / nodejs-pubsub / test / pull-retry.ts View on Github external
it('should return false for non-retryable errors', () => {
      [
        status.INVALID_ARGUMENT,
        status.NOT_FOUND,
        status.PERMISSION_DENIED,
        status.FAILED_PRECONDITION,
        status.OUT_OF_RANGE,
        status.UNIMPLEMENTED,
      ].forEach((code: status) => {
        const shouldRetry = retrier.retry({code} as StatusObject);
        assert.strictEqual(shouldRetry, false);
      });
    });
github cjihrig / grpc-server-js / lib / server.js View on Github external
const kSessionOptions = Symbol('sessionOptions');
const kUnaryHandlerType = 0;
const kClientStreamHandlerType = 1;
const kServerStreamHandlerType = 2;
const kBidiHandlerType = 3;
const kValidContentTypePrefix = 'application/grpc';
const {
  HTTP2_HEADER_CONTENT_TYPE,
  HTTP2_HEADER_STATUS,
  HTTP2_HEADER_PATH,
  HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE,
  NGHTTP2_CANCEL
} = Http2.constants;

const unimplementedStatusResponse = {
  code: status.UNIMPLEMENTED,
  details: 'The server does not implement this method'
};

const unsuportedMediaTypeResponse = {
  [HTTP2_HEADER_STATUS]: HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE
};
const unsuportedMediaTypeResponseOptions = { endStream: true };

const defaultHandler = [
  function unary (call, callback) {
    callback(unimplementedStatusResponse);
  },
  function clientStream (call, callback) {
    callback(unimplementedStatusResponse);
  },
  function serverStream (call) {