1.0.7 • Published 8 years ago

request-service-discovery v1.0.7

Weekly downloads
6
License
ISC
Repository
github
Last release
8 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

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

0.0.25

9 years ago

0.0.24

9 years ago

0.0.23

9 years ago

0.0.22

9 years ago

0.0.21

9 years ago

0.0.20

9 years ago

0.0.19

9 years ago

0.0.18

9 years ago

0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

1.0.0

10 years ago