Skip to content

Instantly share code, notes, and snippets.

@alexkolson
Created December 14, 2010 22:53
Show Gist options
  • Save alexkolson/741279 to your computer and use it in GitHub Desktop.
Save alexkolson/741279 to your computer and use it in GitHub Desktop.
ruleset a369x115 {
meta {
name "StringBin Module"
description <<
StringBin Module
>>
author "AKO"
logging off
provide read, write, destroy
configure using pin = "nopin"
}
global {
datasource write <- "api.stringbin.com/1/write?pin=#{pin}" cachable for 1 second
datasource read <- "api.stringbin.com/1/read?pin=#{pin}" cachable for 1 second
write = function(k,v) {
datasource:write({"key":k,"value":v})
}
read = function(k) {
datasource:read({"key":k})
}
destroy = function(k) {
datasource:write({"key":k,"value":""})
}
}
}
ruleset a369x116 {
meta {
name "SringBin Module Test Harness"
description <<
SringBin Module Test Harness
>>
author "AKO"
logging on
use module a369x115 alias StringBin with pin = "X9ooUUsrR180MkpxZ2N1M"
}
rule write_to_stringbin {
select when pageview ".*"
pre {
stuff = StringBin:write("yellow", "mellow");
}
emit <|
window.countOfThings = 0;
|>;
always {
raise explicit event "read_from_stringbin" with k = "yellow";
}
}
rule read_from_stringbin {
select when explicit read_from_stringbin
pre {
goodness = StringBin:read(event:param("k"));
}
{
emit <|
console.log(window.countOfThings + "\n" + JSON.stringify(goodness, null, 2));
window.countOfThings++;
|>;
}
always {
app:counter += 1 from 1;
raise explicit event "destroy_key_in_stringbin" with k = "yellow";
}
}
rule destroy_key_in_stringbin {
select when explicit destroy_key_in_stringbin
pre {
mcHorsty = StringBin:destroy(event:param("k"));
}
always {
raise explicit event "read_from_stringbin" with k = "yellow" if app:counter < 2;
}
}
}
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 [global] Found 3 rules for RID a369x116
// 2010/12/14 15:52:55 DEBUG Events.pm a369x116 write_to_stringbin Adding to schedule: a369x116 & write_to_stringbin
// 2010/12/14 15:52:55 DEBUG Scheduler.pm a369x116 destroy_key_in_stringbin Schedule iterator returning write_to_stringbin with current RID count 0 and current rule count 1
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 destroy_key_in_stringbin Getting ruleset a369x116 for http://example.com/
// 2010/12/14 15:52:55 DEBUG Repository.pm a369x116 destroy_key_in_stringbin Using cached ruleset for a369x116 (dev) with key ruleset:dev:a369x116 & optimization version 7
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 destroy_key_in_stringbin Found 3 rules for RID a369x116
// 2010/12/14 15:52:55 INFO Rules.pm a369x116 destroy_key_in_stringbin Processing rules for site a369x116
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 destroy_key_in_stringbin Getting ruleset a369x115 for http://example.com/
// 2010/12/14 15:52:55 DEBUG Repository.pm a369x116 destroy_key_in_stringbin Using cached ruleset for a369x115 (dev) with key ruleset:dev:a369x115 & optimization version 7
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 write_to_stringbin Found 3 rules for RID a369x116
// 2010/12/14 15:52:55 DEBUG Events.pm a369x116 read_from_stringbin Adding to schedule: a369x116 & read_from_stringbin
// 2010/12/14 15:52:55 DEBUG Scheduler.pm a369x116 destroy_key_in_stringbin Schedule iterator returning read_from_stringbin with current RID count 0 and current rule count 2
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 read_from_stringbin Rule read_from_stringbin is active
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 read_from_stringbin [selected] read_from_stringbin
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 read_from_stringbin
//------------------- begin rule execution: read_from_stringbin ------------------------
// 2010/12/14 15:52:55 WARN Modules.pm a369x116 read_from_stringbin Datasource for StringBin not found
// 2010/12/14 15:52:55 INFO Rules.pm a369x116 read_from_stringbin fired
// 2010/12/14 15:52:55 DEBUG Actions.pm a369x116 read_from_stringbin blocktype is every
// 2010/12/14 15:52:55 DEBUG Actions.pm a369x116 read_from_stringbin actions list contains 1 actions
// 2010/12/14 15:52:55 DEBUG Postlude.pm a369x116 read_from_stringbin [post] evaling post expressions with rule fired
// 2010/12/14 15:52:55 DEBUG Postlude.pm a369x116 read_from_stringbin [post] evaling consequent
// 2010/12/14 15:52:55 DEBUG Application.pm a369x116 read_from_stringbin GET (counter) using ($VAR1 = {
// 'rid' => 'a369x116',
// 'key' => 'counter'
//};
//) returns: $VAR1 = {
// 'created' => 1292366941,
// 'value' => 2499,
// '_id' => bless( {
// 'value' => '4d07f1ee896d0c5cabeb6c49'
// }, 'MongoDB::OID' ),
// 'rid' => 'a369x116',
// 'serialize' => 0,
// 'key' => 'counter'
//};
// 2010/12/14 15:52:55 DEBUG Application.pm a369x116 read_from_stringbin Store to counter: $VAR1 = {
// 'value' => 2500,
// 'rid' => 'a369x116',
// 'key' => 'counter'
//};
// 2010/12/14 15:52:55 DEBUG Application.pm a369x116 read_from_stringbin GET (counter) using ($VAR1 = {
// 'rid' => 'a369x116',
// 'key' => 'counter'
//};
//) returns: $VAR1 = {
// 'created' => 1292367175,
// 'value' => 2500,
// '_id' => bless( {
// 'value' => '4d07f1ee896d0c5cabeb6c49'
// }, 'MongoDB::OID' ),
// 'rid' => 'a369x116',
// 'serialize' => 0,
// 'key' => 'counter'
//};
// 2010/12/14 15:52:55 DEBUG Postlude.pm a369x116 read_from_stringbin Raising explicit event explicit:destroy_key_in_stringbin for a369x116
// 2010/12/14 15:52:55 DEBUG Postlude.pm a369x116 read_from_stringbin Raising explicit event for RID a369x116, version dev
// 2010/12/14 15:52:55 DEBUG Events.pm a369x116 read_from_stringbin Processing events for a369x116
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 read_from_stringbin Getting ruleset a369x116 for http://example.com/
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 read_from_stringbin Found 3 rules for RID a369x116
// 2010/12/14 15:52:55 DEBUG Events.pm a369x116 destroy_key_in_stringbin Adding to schedule: a369x116 & destroy_key_in_stringbin
// 2010/12/14 15:52:55 DEBUG Scheduler.pm a369x116 destroy_key_in_stringbin Schedule iterator returning destroy_key_in_stringbin with current RID count 0 and current rule count 3
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 destroy_key_in_stringbin Rule destroy_key_in_stringbin is active
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 destroy_key_in_stringbin [selected] destroy_key_in_stringbin
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 destroy_key_in_stringbin
//------------------- begin rule execution: destroy_key_in_stringbin ------------------------
// 2010/12/14 15:52:55 WARN Modules.pm a369x116 destroy_key_in_stringbin Datasource for StringBin not found
// 2010/12/14 15:52:55 INFO Rules.pm a369x116 destroy_key_in_stringbin fired
// 2010/12/14 15:52:55 DEBUG Actions.pm a369x116 destroy_key_in_stringbin blocktype is every
// 2010/12/14 15:52:55 DEBUG Actions.pm a369x116 destroy_key_in_stringbin actions list contains 0 actions
// 2010/12/14 15:52:55 DEBUG Postlude.pm a369x116 destroy_key_in_stringbin [post] evaling post expressions with rule fired
// 2010/12/14 15:52:55 DEBUG Postlude.pm a369x116 destroy_key_in_stringbin [post] evaling consequent
// 2010/12/14 15:52:55 DEBUG Expressions.pm a369x116 destroy_key_in_stringbin Evaling qualified variable app:counter
// 2010/12/14 15:52:55 DEBUG Application.pm a369x116 destroy_key_in_stringbin GET (counter) using ($VAR1 = {
// 'rid' => 'a369x116',
// 'key' => 'counter'
//};
//) returns: $VAR1 = {
// 'created' => 1292367175,
// 'value' => 2500,
// '_id' => bless( {
// 'value' => '4d07f1ee896d0c5cabeb6c49'
// }, 'MongoDB::OID' ),
// 'serialize' => 0,
// 'rid' => 'a369x116',
// 'key' => 'counter'
//};
// 2010/12/14 15:52:55 DEBUG Expressions.pm a369x116 destroy_key_in_stringbin [persistent] app:counter -> 2500
// 2010/12/14 15:52:55 DEBUG Postlude.pm a369x116 destroy_key_in_stringbin [post] Evaluating statement test0
// 2010/12/14 15:52:55 DEBUG Scheduler.pm a369x116 destroy_key_in_stringbin Moving to next RID
// 2010/12/14 15:52:55 DEBUG Scheduler.pm a369x116 destroy_key_in_stringbin Resetting schedule
// 2010/12/14 15:52:55 DEBUG Rules.pm a369x116 destroy_key_in_stringbin Finished processing rules for a369x116
// 2010/12/14 15:52:55 DEBUG AST.pm a369x116 destroy_key_in_stringbin Generating JS for a369x116
// 2010/12/14 15:52:55 DEBUG AST.pm a369x116 destroy_key_in_stringbin Generating resource statement for a369x116
// 2010/12/14 15:52:55 DEBUG Log.pm a369x116 destroy_key_in_stringbin [logging] Storing logging data for a369x116
// 2010/12/14 15:52:55 DEBUG Log.pm a369x116 destroy_key_in_stringbin results for write_to_stringbin
// 2010/12/14 15:52:55 DEBUG Log.pm a369x116 destroy_key_in_stringbin results for read_from_stringbin
// 2010/12/14 15:52:55 DEBUG Log.pm a369x116 destroy_key_in_stringbin results for destroy_key_in_stringbin
// 2010/12/14 15:52:55 DEBUG Log.pm a369x116 destroy_key_in_stringbin TXN_ID: E3B9C912-07D4-11E0-8966-9B7EA56309D5
// 2010/12/14 15:52:55 DEBUG Session.pm a369x116 destroy_key_in_stringbin Cleaning up session
// 2010/12/14 15:52:55 INFO Response.pm a369x116 destroy_key_in_stringbin Event processing finished
// 2010/12/14 15:52:55 DEBUG Response.pm a369x116 destroy_key_in_stringbin __FLUSH__
// 2010/12/14 15:52:56 DEBUG Response.pm a369x116 destroy_key_in_stringbin Called with GET /blue/event/web/pageview/a369x116/129236693176126172351969636476?kvars=%7B%7D&caller=http%3A%2F%2Fexample.com%2F&referer=&title=Example+Web+Page&a369x116:kynetx_app_version=dev HTTP/1.0
// 2010/12/14 15:52:56 DEBUG Response.pm a369x116 destroy_key_in_stringbin Returning javascript from evaluation
// KNS Tue Dec 14 22:52:56 2010
KOBJ.registerClosure('a369x116', function($K) { (function(){var write = function(k, v) {return };
var read = function(k) {return };
var destroy = function(k) {return };
(function(){var stuff = '';
window.countOfThings = 0;
function callBacks () {
};
}());
(function(){var goodness = '';
function callBacks () {
};
console.log(window.countOfThings + "\n" + JSON.stringify(goodness, null, 2));
window.countOfThings++;
;
callBacks();
}());
(function(){var mcHorsty = '';
function callBacks () {
};
}());
}());
KOBJ.logVerify = KOBJ.logVerify || function(t,a,c){};KOBJ.logVerify('E3B9C912-07D4-11E0-8966-9B7EA56309D5', 'a369x116', 'cs.kobj.net'); }, '129236693176126172351969636476');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment