• This repository has been archived on 10/Jan/2019
  • Stars
    star
    330
  • Rank 126,913 (Top 3 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 13 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Persistent (and fast!) push feeds, queues, and jobs leveraging Redis

Thoonk

What is Thoonk?

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 thoonk.js, such as the Python version thoonk.py.

Installing

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.

Example

First, we create our model definition in examples/helloworld.js:

var ThoonkInterface = require('thoonk').ThoonkBaseInterface;


function HelloWorld(thoonk) {
    // Link the HelloWorld object to a thoonk connection.
    ThoonkInterface.call(this, thoonk);
}

HelloWorld.prototype = Object.create(ThoonkInterface.prototype);

// Set a unique type name for our HelloWorld model
HelloWorld.prototype.objtype = 'helloworld'; 

// Specify where to load Lua scripts from for our model
HelloWorld.prototype.scriptdir = __dirname + '/scripts';

(function () {

    this.greet = function (firstName, lastName, cb) {
        this.runScript('greet', [firstName, lastName], cb);
    };

}).call(HelloWorld.prototype);


module.exports = HelloWorld;

Then we create the Lua script we need in examples/scripts/greet.lua:

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');

thoonk.registerInterface('HelloWorld', HelloWorld, function () {
    // All scripts have been loaded and event subscriptions initialized.

    var hello = thoonk.objects.HelloWorld();

    hello.greet('Arthur', 'Dent', function (err, result) {
        if (err) {
            console.error(err);
        } else {
            console.log(result);
            // >>> Hello, Arthur Dent
        }
    });
});

Addons

License

MIT

Created By

If you like this, follow: @fritzy on twitter.

More Repositories

1

thoonk.py

Persistent (and fast!) push feeds, queues, and jobs leveraging Redis.
Python
355
star
2

yeti.css

&yet's visual style and pattern library
Stylus
170
star
3

ConsoleDummy.js

Super lightweight solution that lets you leave `console` statements in your JS.
JavaScript
60
star
4

yeti-guide

&yet standards for writing sane and maintainable front-end systems
CSS
25
star
5

yeti-threads

JavaScript
20
star
6

face.camp

Take animated gifs and post them to your fave Slack channel.
JavaScript
14
star
7

json-rpc-ws

JavaScript
11
star
8

padlock

An execution locking mechanism for Node.js
JavaScript
8
star
9

paddle

Paddle ensures your callback runs and calls your error if it hasn't. You are up a creek; here is your paddle.
JavaScript
6
star
10

slack-ship

ah, nostalgia
JavaScript
5
star
11

MotherMayI

MotherMayI is a simple Node.js ACL lib/schema using Redis.
JavaScript
3
star
12

postflux

JavaScript
3
star
13

autofocus.js

JavaScript
3
star
14

fluentconf-native-web-apps

2
star
15

Thoonk-Scripts

The Redis-Lua Scripts Used for Thoonk
2
star
16

textcapades-legacy

JavaScript
2
star
17

triconftweets

Live twitter feed for TriConf
2
star
18

eslint-config-andyet

our eslint config(s)
JavaScript
1
star
19

node

dockerfiles to install node in an alpine based container
1
star
20

jsft-api

CSS
1
star
21

shippy.js

JS SDK for shippy
JavaScript
1
star
22

bell-andyet

A bell authentication module for andyet auth
JavaScript
1
star
23

wolves

JavaScript
1
star
24

SleekPubsub2

XMPP Publish-Subscribe, based on SleekXMPP and Thoonk.py
Python
1
star
25

textcapades

JavaScript
1
star
26

passport-andyet

A passport plugin for andyet auth
JavaScript
1
star
27

flashlightapp.info

The AMAZING HTML5 flashlight app
1
star