Socket
Socket
Sign inDemoInstall

google-gax

Package Overview
Dependencies
13
Maintainers
3
Versions
354
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    google-gax

Google API Extensions


Version published
Weekly downloads
4.8M
increased by3.91%
Maintainers
3
Install size
27.0 MB
Created
Weekly downloads
 

Package description

What is google-gax?

The google-gax (Google API Extensions) package is a set of libraries for making Google API client libraries. It provides functionality such as automatic retries, page iteration, and request bundling. It is mainly used internally by Google's auto-generated client libraries for Node.js.

What are google-gax's main functionalities?

Automatic Retries

This feature allows developers to specify retry logic for failed requests. The RetryOptions class can be used to define backoff settings for retries.

const {RetryOptions} = require('google-gax');
const retryOptions = new RetryOptions(
  [100, 200, 400, 800, 1600],
  RetryOptions.createRetryPolicy()
);

Page Iteration

This feature simplifies the process of iterating over multiple pages of API response data. The createApiCall function can be configured to handle pagination automatically.

const {createApiCall} = require('google-gax');
const apiCall = createApiCall(
  promiseFunc,
  {autoPaginate: true}
);
const resources = [];
apiCall({},
  (err, response, nextPageRequest, rawResponse) => {
    resources.push(...response);
    if (nextPageRequest) {
      // More results to fetch
    }
  }
);

Request Bundling

Request bundling allows developers to combine multiple API calls into a single request to reduce network overhead. The BundleDescriptor and BundleExecutor classes are used to define and execute bundled requests.

const {BundleDescriptor, BundleExecutor} = require('google-gax');
const descriptor = new BundleDescriptor(
  'bundled_field',
  ['field1', 'field2'],
  'bundled_field',
  1024
);
const executor = new BundleExecutor({descriptor});

Other packages similar to google-gax

Readme

Source
Google Inc. logo

Google API Extensions for Node.js

Release Level npm version

Google API Extensions for Node.js (gax-nodejs) is a set of modules which aids the development of APIs for clients and servers based on gRPC and Google API conventions.

Application code will rarely need to use most of the classes within this library directly, but code generated automatically from the API definition files in Google APIs can use services such as page streaming and request bundling to provide a more convenient and idiomatic API surface to callers.

Installation

$ npm install google-gax

Supporting older version of Node.js

This library uses grpc-js package for communicating with API server, and it uses HTTP/2 functionality that is only available in Node.js v8.13.0 or newer. If you need to use this library with older versions of Node.js, you need to make your code depend on a legacy gRPC library (grpc) and pass the instance of gRPC to the client constructor:

const grpc = require('grpc');
const client = new APIClient({ grpc }); // APIClient is the client class you use, e.g. SpeechClient, etc.

Contributing

Contributions to this library are always welcome and highly encouraged. See the CONTRIBUTING documentation for more information on how to get started.

Details

For detailed documentation of the modules in gax-nodejs, please check out the docs.

License

BSD - See LICENSE for more information.

Keywords

FAQs

Last updated on 19 Jan 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc