Thoonk is a persistent (and fast!) system for push feeds, queues, and jobs which leverages Redis. Thoonk follows a contract (schema + behavior) to allow multiple languages and custom implementations to interact reliably.
Thoonk is a persistent (and fast!) framework for Redis backed live data and objects, such as push feeds, queues, and jobs.
Thoonk lets you create a Model whose methods are mapped to Redis Lua scripts, and can listen for and emit events using Redis pubsub channels.
Since all of the actual logic for the model is written in Lua, Thoonk wrappers
for other languages can be written which can interoperate with
such as the Python version
npm install thoonk
By itself, Thoonk is just a small framework for marshalling and setting up subscriptions and loading Lua scripts into Redis. To see Thoonk in action you will want to look at the examples for how to build a Thoonk backed model.
First, we create our model definition in
var ThoonkInterface = require'thoonk'ThoonkBaseInterface;// Link the HelloWorld object to a thoonk connection.ThoonkInterfacecallthis thoonk;ObjectcreateThoonkInterfaceprototype;// Set a unique type name for our HelloWorld model'helloworld';// Specify where to load Lua scripts from for our model__dirname + '/scripts';thisrunScript'greet' firstName lastName cb;;callHelloWorldprototype;moduleexports = HelloWorld;
Then we create the Lua script we need in
local firstName, lastName = unpack(ARGV);return "Hello, " .. firstName .. " " .. lastName;
And finally, when we want to use our HelloWorld model:
var thoonk = require'thoonk'createClient;var HelloWorld = require'helloworld';thoonkregisterInterface'HelloWorld' HelloWorld// All scripts have been loaded and event subscriptions initialized.var hello = thoonkobjectsHelloWorld;hellogreet'Arthur' 'Dent'if errconsole.errorerr;elseconsole.logresult;// >>> Hello, Arthur Dent;;
If you like this, follow: @fritzy on twitter.