From 5e94e97fe5cdf5b96cc6d134970c02aeee228615 Mon Sep 17 00:00:00 2001 From: travis-ci Date: Mon, 4 Jul 2016 15:32:28 +0200 Subject: [PATCH] Update documentation --- README.md | 84 +++++++++++++++++++++++++++++++++++++++++----- docker-compose.yml | 2 +- 2 files changed, 76 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index de828de..9cd1bf2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Coverage Status](https://coveralls.io/repos/github/CoorpAcademy/squirrel/badge.svg?branch=master)](https://coveralls.io/github/CoorpAcademy/squirrel?branch=master) # squirrel -Watch etcd folder and keep it synchronized. +Keep a replication of ETCD folder locally for low latency querying. ## Install ```shell @@ -11,27 +11,93 @@ $ npm install --save @coorpacademy/squirrel ## Usage -### Command Line Interface +### Node interface + +```JavaScript +const squirrel = createSquirrel({ + hosts: 'http://localhost:2379', + auth: null, + ca: null, + key: null, + cert: null, + + cwd: '/', + fallback: '/tmp/squirrel.json', + indexes: ['foo', 'bar.baz'] +}); ``` -squirrel-sync --hosts localhost:2379,localhost:2379 ./my-folder /etcd-folder -squirrel-watch --hosts localhost:2379,localhost:2379 /etcd-folder + +Options: +- `hosts`: ETCD hosts. [more](https://github.com/stianeikeland/node-etcd/#etcdhosts--1270012379-options) +- `auth`: A hash containing `{user: "username", pass: "password"}` for basic auth. [more](https://github.com/stianeikeland/node-etcd/#constructor-options) +- `ca`: Ca certificate. [more](https://github.com/stianeikeland/node-etcd/#constructor-options) +- `key`: Client key. [more](https://github.com/stianeikeland/node-etcd/#constructor-options) +- `cert`: Client certificate. [more](https://github.com/stianeikeland/node-etcd/#constructor-options) +- `cwd`: ETCD current working directory. +- `fallback`: Temporary file to save ETCD replicat. +- `indexes`: Array of key to index. + +#### Methods + +- `get` + +Get file by path. Return `Promise`; + +```JavaScript +const foo = await squirrel.get('/foo'); +console.log(foo); // foo's content ``` -### Retrieve a Client +- `getBy` +Get by index value. Return `Promise`; +```JavaScript +const foo = await squirrel.getBy('foo', 'bar'); +console.log(foo); // { foo: 'bar' } -## Test -You may run test with +const barBaz = await squirrel.getBy('bar.baz', 'qux'); +console.log(barBaz); // { bar: { baz: 'qux' } } ``` -$ npm test + +Use internally [`_.get`](https://lodash.com/docs#get). + +- `getAll` + +Get index Map. Return `Promise`; + +```JavaScript +const foo = await squirrel.getAll('foo'); +console.log(foo); // { bar: { foo: 'bar' } } ``` -Please note that test use an actual etcd service +### Command Line Interface + +- `squirrel-sync` + +Synchronise FS folder with ETCD folder. + +```Bash +$ squirrel-sync --hosts localhost:2379 ./fs-folder /etcd-folder +``` + + +- `squirrel-watch` +Watch ETCD folder change. +```Bash +$ squirrel-watch --hosts localhost:2379 /etcd-folder +``` + +## Test +You may run test with + +```Bash +$ npm test +``` ## [Marble](./MARBLE.md) diff --git a/docker-compose.yml b/docker-compose.yml index dc4e05f..74db89e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,4 +3,4 @@ etcd: ports: - "2379:2379" - "4001:4001" - command: -listen-client-urls 'http://0.0.0.0:2379,http://0.0.0.0:4001' -advertise-client-urls 'http://0.0.0.0:2379,http://0.0.0.0:4001' + command: etcd --listen-client-urls 'http://0.0.0.0:2379' --advertise-client-urls 'http://0.0.0.0:2379'