Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[example] added example of by and expire reactors
  • Loading branch information
jcrugzz committed May 6, 2013
1 parent 3139afb commit 7f5ba3a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
36 changes: 36 additions & 0 deletions example/client.js
@@ -0,0 +1,36 @@
/*
* client.js :: A client example showing 2 generic producers
*
* (C) 2013 Nodejitsu Inc.
*
*/

var godot = require('../lib/godot');

//
// This client will expire only once you turn off this client script
//
godot.createClient({
type: 'tcp',
producers: [
godot.producer({
host: '127.0.0.1',
service: 'ohai/there',
ttl: 1000 * 4
})
]
}).connect(1337);

//
// This client will expire on the first tick
//
godot.createClient({
type: 'tcp',
producers: [
godot.producer({
host: '127.0.0.1',
service: 'new/things',
ttl: 1000 * 6
})
]
}).connect(1337);
26 changes: 26 additions & 0 deletions example/server.js
@@ -0,0 +1,26 @@
/*
* server.js :: An example server with fun reactor things happening
*
* (C) 2013 Nodejits Inc.
*
*/

var godot = require('../lib/godot'),
expire = godot.reactor().expire(5000);

//
// This example shows a way to meausre two separate clients on the same
// `reactor` using the power of the `by` reactor. It will create a new reactor
// pipe-chain for each different 'service' in this case to easily assess the
// expiration of two separate `producers`.
//
godot.createServer({
type: 'tcp',
reactors: [
godot.reactor()
.by('service',
expire
.console()
)
]
}).listen(1337);

0 comments on commit 7f5ba3a

Please sign in to comment.