This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruleset a369x115 { | |
meta { | |
name "StringBin Module" | |
description << | |
StringBin Module | |
>> | |
author "AKO" | |
logging off | |
provide read, write, destroy | |
configure using pin = "nopin" | |
} | |
global { | |
datasource write <- "http://api.stringbin.com/1/write?" cachable for 1 second | |
datasource read <- "http://api.stringbin.com/1/read?" cachable for 1 second | |
write = function(k,v) { | |
datasource:write({"pin":pin,"key":k,"value":v}) | |
} | |
read = function(k) { | |
datasource:read({"pin":pin,"key":k}) | |
} | |
destroy = function(k) { | |
datasource:write({"pin":pin,"key":k,"value":""}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment