Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@elastic/transport

Package Overview
Dependencies
Maintainers
75
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elastic/transport

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

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
556K
increased by20.9%
Maintainers
75
Weekly downloads
 
Created

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

FAQs

Package last updated on 12 Aug 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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc