How to use the @google-cloud/common.util.getUserAgentFromPackageJson function in @google-cloud/common

To help you get started, we’ve selected a few @google-cloud/common 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 googleapis / google-cloud-node / packages / common-grpc / src / service.js View on Github external
this.grpcMetadata.add('x-goog-api-client', [
    'gl-node/' + process.versions.node,
    'gccl/' + config.packageJson.version,
    'grpc/' + require('grpc/package.json').version
  ].join(' '));

  if (config.grpcMetadata) {
    for (var prop in config.grpcMetadata) {
      if (config.grpcMetadata.hasOwnProperty(prop)) {
        this.grpcMetadata.add(prop, config.grpcMetadata[prop]);
      }
    }
  }

  this.maxRetries = options.maxRetries;
  this.userAgent = util.getUserAgentFromPackageJson(config.packageJson);

  this.activeServiceMap_ = new Map();
  this.protos = {};

  var protoServices = config.protoServices;

  var self = this;

  Object.keys(protoServices).forEach(function(name) {
    var protoConfig = protoServices[name];
    var service = self.loadProtoFile_(protoConfig, config);

    self.protos[name] = service;

    if (protoConfig.baseUrl) {
      service.baseUrl = protoConfig.baseUrl;
github firebase / user-privacy / functions / node_modules / @google-cloud / common-grpc / src / service.js View on Github external
this.grpcMetadata.add('x-goog-api-client', [
    'gl-node/' + process.versions.node,
    'gccl/' + config.packageJson.version,
    'grpc/' + require('grpc/package.json').version
  ].join(' '));

  if (config.grpcMetadata) {
    for (var prop in config.grpcMetadata) {
      if (config.grpcMetadata.hasOwnProperty(prop)) {
        this.grpcMetadata.add(prop, config.grpcMetadata[prop]);
      }
    }
  }

  this.maxRetries = options.maxRetries;
  this.userAgent = util.getUserAgentFromPackageJson(config.packageJson);

  this.activeServiceMap_ = new Map();
  this.protos = {};

  var protoServices = config.protoServices;

  var self = this;

  Object.keys(protoServices).forEach(function(name) {
    var protoConfig = protoServices[name];
    var service = self.loadProtoFile_(protoConfig, config);

    self.protos[name] = service;

    if (protoConfig.baseUrl) {
      service.baseUrl = protoConfig.baseUrl;