New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

request-service-discovery

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-service-discovery

An extension to request to facilitate making requests against discoverable services

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Request Service Discovery

Utility module for making HTTP requests against discoverable services registered with ZooKeeper.

NPM

Basic Usage

The following is the most basic usage of the client;

'use strict';

var RequestServiceDiscovery = require('request-service-discovery');

// Instantiate a client
var client = new RequestServiceDiscovery({
  connectionString: '127.0.0.1:2181',
  basePath: 'services',
  serviceName: 'my/service/v1',
  providerStrategy: 'RoundRobin',
  verbose: false,
  timeout: 1000,
  retries: 2,
  minTimeout: 5,
  maxTimeout: 50,
  correlationHeaderName: 'My-Correlation-ID',
  connectTimeout: 5000,
  sessionTimeout: 30000
});

var query = {
  "myParam": "myValue"  
};

var headers = {
  "Content-Type": "application/json"  
};

var body = {
 "prop1": "value1",
 "prop2": "value2"  
};

client.on('connected', function() {

  // Invoke a GET request against the service
  client.get('item/search', { query: query, headers: headers }, function(err, res) {
    callback(err, res.body);
  });

  // Invoke a PUT request against the service
  client.put('item', { query: query, headers: headers }, body, function(err, res) {
    callback(err, res.body);
  });

  // Invoke a POST request against the service
  client.post('item', { query: query, headers: headers }, body, function(err, res) {
    callback(err, res.body);
  });

  // Invoke a DELETE request against the service
  client.delete('item', { query: query, headers: headers }, body, function(err, res) {
    callback(err, res.body);
  });

  // Invoke a GET request against the service
  client.method('item/search', { method: 'GET', query: query, headers: headers }, body, (err, res) {
    callback(err, res.body);
  });

});

FAQs

Package last updated on 21 Sep 2017

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