1.0.7 • Published 7 years ago

request-service-discovery v1.0.7

Weekly downloads
6
License
ISC
Repository
github
Last release
7 years ago

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);
  });

});
1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

0.0.25

8 years ago

0.0.24

8 years ago

0.0.23

8 years ago

0.0.22

8 years ago

0.0.21

8 years ago

0.0.20

8 years ago

0.0.19

8 years ago

0.0.18

8 years ago

0.0.17

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

9 years ago

0.0.1

9 years ago

1.0.0

9 years ago