Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
travis-ci committed Jul 4, 2016
1 parent 0753c5e commit d1096c4
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 10 deletions.
100 changes: 91 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -11,27 +11,109 @@ $ 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

Consider


```Bash
/
├── bar
│   └── baz { "bar": { "baz": "qux" } }
└── foo { "foo": "bar" }
```
### Retrieve a Client
- `get`
Get file by path. Return `Promise`;
```JavaScript
const foo = await squirrel.get('/foo');
console.log(foo); // { "foo": "bar" }

## Test
You may run test with
const barBaz = await squirrel.get('/bar/baz');
console.log(barBaz); // { "bar": { "baz": "qux" } }
```
$ npm test
- `getBy`
Get by index value. Return `Promise`;
```JavaScript
const foo = await squirrel.getBy('foo', 'bar');
console.log(foo); // { "foo": "bar" }

const barBaz = await squirrel.getBy('bar.baz', 'qux');
console.log(barBaz); // { "bar": { "baz": "qux" } }
```
Please note that test use an actual etcd service
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" } }

const barBaz = await squirrel.getAll('bar.baz');
console.log(barBaz); // { "qux" : { "bar": { "baz": "qux" } } }
```
### 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)
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit d1096c4

Please sign in to comment.