Update README and examples

This commit is contained in:
haad 2016-03-03 15:16:27 +01:00
parent 00db5728e9
commit 2c4381e7d5
4 changed files with 20 additions and 11 deletions

View File

@ -21,13 +21,18 @@ npm install
Key-Value store example:
```
node examples/keyvalue.js <channel> <username> <key> <value>
node examples/keyvalueReader.js <channel> <username> <key>
node examples/keyvalue.js <host> <username> <channel> <key> <value>
node examples/keyvalueReader.js <host> <username> <channel> <key>
```
Event log example (run several in separate shells):
```
node examples/reader.js <channel> <username> <data> <interval in ms>
node examples/reader.js <host> <username> <channel> <data> <interval in ms>
```
Benchmark writes:
```
node examples/benchmark.js <host> <username> <channel>;
```
## API

View File

@ -5,8 +5,10 @@ const await = require('asyncawait/await');
const OrbitClient = require('../src/OrbitClient');
const Timer = require('./Timer');
// usage: keyvalue.js <host> <username> <channel> <key> <value>
// orbit-server
const host = 'localhost';
const host = process.argv[2] ? process.argv[2] : 'localhost'
const port = 3333;
const username = process.argv[3] ? process.argv[3] : 'LambOfGod';
@ -15,14 +17,14 @@ const password = '';
let run = (async(() => {
try {
const orbit = OrbitClient.connect(host, port, username, password);
const channel = process.argv[2] ? process.argv[2] : 'testing123';
const channel = process.argv[4] ? process.argv[4] : 'testing123';
const db = orbit.channel(channel);
let count = 1;
while(true) {
const key = process.argv[4] ? process.argv[4] : 'greeting';
const value = process.argv[5] ? process.argv[5] : 'Hello world';
const key = process.argv[5] ? process.argv[5] : 'greeting';
const value = process.argv[6] ? process.argv65] : 'Hello world';
const timer = new Timer(true);
db.put(key, value + " " + count);
const result = db.get(key);

View File

@ -5,8 +5,10 @@ const await = require('asyncawait/await');
const OrbitClient = require('../src/OrbitClient');
const Timer = require('./Timer');
// usage: keyvalueReader.js <host> <username> <channel> <key>
// orbit-server
const host = 'localhost';
const host = process.argv[2] ? process.argv[2] : 'localhost'
const port = 3333;
const username = process.argv[3] ? process.argv[3] : 'LambOfGod';
@ -15,13 +17,13 @@ const password = '';
let run = (async(() => {
try {
const orbit = OrbitClient.connect(host, port, username, password);
const channel = process.argv[2] ? process.argv[2] : 'testing123';
const channel = process.argv[4] ? process.argv[4] : 'testing123';
const db = orbit.channel(channel);
let count = 1;
setInterval(async(() => {
const key = process.argv[4] ? process.argv[4] : 'greeting';
const key = process.argv[5] ? process.argv[5] : 'greeting';
let timer = new Timer(true);
const result = db.get(key);

View File

@ -5,7 +5,7 @@ const await = require('asyncawait/await');
const OrbitClient = require('../src/OrbitClient');
const Timer = require('./Timer');
// usage: reader.js <host> <username> <channel> <text> <interval>
// usage: reader.js <host> <username> <channel> <data> <interval in ms>
// orbit-server
const host = process.argv[2] ? process.argv[2] : 'localhost'