Skip to content

Commit 480cc60

Browse files
committedDec 27, 2015
More readme updates, added debugging help
1 parent 886505d commit 480cc60

File tree

1 file changed

+44
-9
lines changed

1 file changed

+44
-9
lines changed
 

‎README.md

+44-9
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ $ npm install node-etcd@3.0.2
2323
## Changes
2424

2525
- 5.0.0
26-
- Supports basic auth.
27-
- Breaking: Constructor changes
28-
- Breaking: Must provide https url to use https
29-
26+
- Supports basic auth, timeout, etc. See options.
27+
- **Breaking**: Constructor changes (see below)
28+
- **Breaking**: Must provide https url to use https
3029
- 4.2.1
3130
- Newer deasync fixes issues with iojs 3.3.0 and nodejs 4.0.0.
3231
- 4.1.0
@@ -423,9 +422,9 @@ Provide `ca`, `cert`, `key` as options. Remember to use `https`-url.
423422
var fs = require('fs');
424423

425424
var options = {
426-
ca: fs.readFileSync('ca.pem'),
427-
cert: fs.readFileSync('cert.pem'),
428-
key: fs.readFileSync('key.pem')
425+
ca: fs.readFileSync('ca.pem'),
426+
cert: fs.readFileSync('cert.pem'),
427+
key: fs.readFileSync('key.pem')
429428
};
430429

431430
var etcdssl = new Etcd("https://localhost:4001", options);
@@ -439,14 +438,14 @@ Pass a hash containing username and password as auth option to use basic auth.
439438
var auth = {
440439
user: "username",
441440
pass: "password"
442-
}
441+
};
443442

444443
var etcd = new Etcd("localhost:4001", { auth: auth });
445444
```
446445

447446
## Constructor options
448447

449-
Useful constructor options include:
448+
Pass in a hash after server in the constructor to set options. Some useful constructor options include:
450449

451450
- `timeout` - Integer request timeout in milliseconds to wait for server response.
452451
- `ca` - Ca certificate
@@ -455,6 +454,42 @@ Useful constructor options include:
455454
- `passphrase` - Client key passphrase
456455
- `auth` - A hash containing `{user: "username", pass: "password"}` for basic auth.
457456

457+
```javascript
458+
var etcd = new Etcd("127.0.0.1:4001", { timeout: 1000, ... });'
459+
```
460+
461+
## Debugging
462+
463+
Nodejs `console.log`/`console.dir` truncates output to a couple of levels -
464+
often hiding nested errors. Use `util.inspect` to show inner errors.
465+
466+
```javascript
467+
etcd.get('key', function(err, val) {
468+
console.log(require('util').inspect(err, true, 10));
469+
});
470+
471+
//{ [Error: All servers returned error]
472+
// [stack]: [Getter/Setter],
473+
// [message]: 'All servers returned error',
474+
// errors:
475+
// [ { server: 'https://localhost:2379',
476+
// httperror:
477+
// { [Error: Hostname/IP doesn't match certificate's altnames: "Host: localhost. is not cert's CN: undefined"]
478+
// [stack]: [Getter/Setter],
479+
// [message]: 'Hostname/IP doesn\'t match certificate\'s altnames: "Host: localhost. is not cert\'s CN: undefined"',
480+
// reason: 'Host: localhost. is not cert\'s CN: undefined',
481+
// host: 'localhost.',
482+
// cert:
483+
// { subject: { C: 'USA', O: 'etcd-ca', OU: 'CA' },
484+
// issuer: { C: 'USA', O: 'etcd-ca', OU: 'CA' } } },
485+
// httpstatus: undefined,
486+
// httpbody: undefined,
487+
// response: undefined,
488+
// timestamp: Sun Dec 27 2015 23:05:15 GMT+0100 (CET) },
489+
// [length]: 1 ],
490+
// retries: 0 }
491+
```
492+
458493
## FAQ:
459494

460495
- Are there any order of execution guarantees when doing multiple requests without using callbacks?

0 commit comments

Comments
 (0)
Please sign in to comment.