Socket
Socket
Sign inDemoInstall

@elastic/transport

Package Overview
Dependencies
6
Maintainers
75
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elastic/transport

Transport classes and utilities shared among Node.js Elastic client libraries


Version published
Maintainers
75
Created

Package description

What is @elastic/transport?

@elastic/transport is a low-level HTTP transport library for Node.js, designed to be used with Elasticsearch clients. It provides the core functionality for making HTTP requests to Elasticsearch clusters, handling retries, and managing connections.

What are @elastic/transport's main functionalities?

Basic HTTP Request

This feature allows you to make basic HTTP requests to an Elasticsearch cluster. The code sample demonstrates how to create a Transport instance and make a GET request to the root endpoint of the Elasticsearch cluster.

const { Transport } = require('@elastic/transport');

const transport = new Transport({
  node: 'http://localhost:9200'
});

async function makeRequest() {
  const response = await transport.request({
    method: 'GET',
    path: '/'
  });
  console.log(response.body);
}

makeRequest();

Handling Retries

This feature allows you to configure the number of retries for failed requests. The code sample demonstrates how to set up a Transport instance with a maximum of 3 retries and handle the request failure.

const { Transport } = require('@elastic/transport');

const transport = new Transport({
  node: 'http://localhost:9200',
  maxRetries: 3
});

async function makeRequest() {
  try {
    const response = await transport.request({
      method: 'GET',
      path: '/'
    });
    console.log(response.body);
  } catch (error) {
    console.error('Request failed after 3 retries:', error);
  }
}

makeRequest();

Connection Pooling

This feature allows you to manage multiple connections to different nodes in an Elasticsearch cluster. The code sample demonstrates how to create a Transport instance with a pool of nodes and make a request.

const { Transport } = require('@elastic/transport');

const transport = new Transport({
  nodes: [
    'http://localhost:9200',
    'http://localhost:9201'
  ]
});

async function makeRequest() {
  const response = await transport.request({
    method: 'GET',
    path: '/'
  });
  console.log(response.body);
}

makeRequest();

Other packages similar to @elastic/transport

Readme

Source

Elasticsearch Node.js Transport

js-standard-style Node CI codecov NPM downloads

This is a HTTP transport Node.js library for communicate with Elastic products, like Elasticsearch.

Install

npm install @elastic/transport

Node.js support

NOTE: The minimum supported version of Node.js is v12.

The client versioning follows the Elastc Stack versioning, this means that major, minor, and patch releases are done following a precise schedule that often does not coincide with the Node.js release times.

To avoid support insecure and unsupported versions of Node.js, the client will drop the support of EOL versions of Node.js between minor releases. Typically, as soon as a Node.js version goes into EOL, the client will continue to support that version for at least another minor release. If you are using the client with a version of Node.js that will be unsupported soon, you will see a warning in your logs (the client will start logging the warning with two minors in advance).

Unless you are always using a supported version of Node.js, we recommend defining the client dependency in your package.json with the ~ instead of ^. In this way, you will lock the dependency on the minor release and not the major. (for example, ~7.10.0 instead of ^7.10.0).

Node.js VersionNode.js EOL dateEnd of support
8.xDecember 20197.11 (early 2021)
10.xApril 20217.12 (mid 2021)

API

Usage

License

This software is licensed under the Apache 2 license.

FAQs

Package last updated on 11 Mar 2021

Did you know?

Socket

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc