How to use the grpc.InterceptingCall function in grpc

To help you get started, we’ve selected a few grpc 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 firecomm / firecomm / examples / vanilla_gRPC / interceptorProvider.js View on Github external
next(metadata, newListener);
    },
    sendMessage: function(message, next) {
      // console.log("sendmessage", message);
      next(message);
    },
    halfClose: function(next) {
      // console.log("halfclose");
      next();
    },
    cancel: function(message, next) {
      // console.log("cancel", message);
      next();
    }
  };
  return new grpc.InterceptingCall(nextCall(options), requester);
};
github sparkswap / broker-cli / utils / grpc-deadline-interceptor.js View on Github external
function grpcDeadlineInterceptor (options, nextCall) {
  // The method_definition object is defined in the grpc nodejs docs here:
  // https://grpc.io/grpc/node/grpc.html#~MethodDefinition
  const {
    requestStream,
    responseStream
  } = options.method_definition

  // If the request is a stream, then we do not want to set a deadline. Setting
  // a deadline on a stream will break it at that particular interval.
  if (requestStream || responseStream) {
    return new grpc.InterceptingCall(nextCall(options))
  }

  // Check to make sure deadline isn't set in the individual options of a specific call
  if (!options.hasOwnProperty('deadline')) {
    options.deadline = grpcDeadline()
  }

  return new grpc.InterceptingCall(nextCall(options))
}
github instana / nodejs-sensor / test / tracing / protocols / grpc / client.js View on Github external
var loggingInterceptor = function(options, nextCall) {
  return new grpc.InterceptingCall(nextCall(options), {
    sendMessage: function(message, next) {
      pinoLogger.warn('intercepted', message);
      next(message);
    }
  });
};
github Opteo / google-ads-node / src / lib / interceptor.ts View on Github external
public intercept(options: grpc.CallOptions, nextCall: NextCall): grpc.InterceptingCall {
    if (isMutationRequest(options)) {
      return new grpc.InterceptingCall(nextCall(options), this.requestInterceptor);
    }
    return new grpc.InterceptingCall(nextCall(options), this.blankInterceptor);
  }
github Opteo / google-ads-node / src / lib / interceptor.ts View on Github external
public intercept(options: grpc.CallOptions, nextCall: NextCall): grpc.InterceptingCall {
    if (isMutationRequest(options)) {
      return new grpc.InterceptingCall(nextCall(options), this.requestInterceptor);
    }
    return new grpc.InterceptingCall(nextCall(options), this.blankInterceptor);
  }
github cheneyweb / nodetracing / client / nodetracing_modules / nodetracing / src / Instrument.js View on Github external
return (options, nextCall) => {
            return new grpc.InterceptingCall(nextCall(options), {
                start: function (metadata, listener, next) {
                    let parent = getParent(asyncHooks.triggerAsyncId())
                    if (parent) {
                        tracer.inject(parent.span, 'FORMAT_GRPC_METADATA', metadata)
                    }
                    next(metadata, listener)
                }
            })
        }
    }