Skip to content
Permalink
Browse files

[example] added example of by and expire reactors

  • Loading branch information...
jcrugzz committed May 6, 2013
1 parent 3139afb commit 7f5ba3ac1fbf225e3c695b494be4914ea932e343
Showing with 62 additions and 0 deletions.
  1. +36 −0 example/client.js
  2. +26 −0 example/server.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);
@@ -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.
You can’t perform that action at this time.