Giter Club home page Giter Club logo

lancaster's Introduction

Lancaster

Version 0.0.3

Build Status

Lancaster provides a REST based application server that lets you configure processing topologies you inject data into and recieve results from.

// example message
{at: 1386197370482, value: 100.00}

Running the Lancaster server provids you with an empty topology.

You create nodes in the Lancaster topology.

Any node in the toplogy can have a message injected in to it.

Each node has a procssing function that is applied to messages is receives. The default function is a passthru that outputs the same message it receives.

Nodes can have attributes set on them that can be changed at any time, and can be used or changed by the node's function.

A predefined set of functions is available. User defined functions can be provided to the topology as part of it's configuraion.

A node can have any number of source nodes, allowing you to create signal processing and switching chains, and combine multiple inputs in to a single output stream.

The topology can be managed via Node.js or a REST API.

Results can be streamed out in real time via a Node.js event emitter or over http via sock.js.

Installing

Landcaster requires Redis.

npm install lancaster

Either clone the repo, edit config.js and use node server.js or

var Lancaster = require('lancaster');
var config = require('config.js');
var server = new Lancaster(config);
server.start();
server.on('start', function(){
  // do stuff
});

The server object provides and api, and a REST server is started for http access.

git clone https://github.com/simonswain/lancaster.git
cd lancaster
npm install
cp config.sample.js config.js
node server

Topology methods

quit (done)

reset (done)

setAttrs (id, attrs, done)

getAttrs (id, done)

attrs (id, attrs, done)

delAttrs (id, done)

addSource (id, source_id, done)

delSource (id, source_id, done)

getSources (id, done)

delSources (id, done)

getTargets (id, done)

setData (id, data, done)

getData (id, done)

setSources (id, sources, done)

get (id, done)

all (done)

add (node, done)

del (id, done)

inject (id, data, done)

extract (done)

Server REST methods

Get server config

GET /

{"lancaster":{"env":"dev","redis":{"host":"127.0.0.1","port":6379,"prefix":"lancaster_dev"},"host":"0.0.0.0","port":4002}}

Get server status

GET /

{"status":"ok"}

Ping test to check server is up

GET /ping

{pong: <unix-epoch-ms>}

Restore the topology to a pristine state (no nodes)

POST /reset

Get all nodes in the Topology

GET /nodes

{'id': {node}, ...}

Get a specific node

GET /nodes/:id

{node}

Add a node to topology

POST /nodes

{
  id: 'xxx',
  fn:'fn-slug',
  sources[id, id, id]
  '<attr>': <value>',
  '<attr>': <value>',
  ...
}

The id, fnandsources` keys are reserved. Any other keys can be used for attrs. Attrs will be used by the fn to control it's operation.

Change attrs on a node. Cannot change id, sources or fn

POST /nodes/:id

{
  '<attr>': <value>',
  '<attr>': <value>',
  ...
}

Inject a message in to a node

POST /nodes/:id/message

{message}

Delete a specific node

DELETE /nodes/:id

Inject a message in to a node

GET /nodes/:id/message

{message}

curl examples

./lancaster start

curl -i -X GET http://localhost:4002/ping

{
  "pong": 1386800817607
}

curl -i -X GET http://localhost:4002/nodes

{}


curl -i -X GET http://localhost:4002/nodes/unknown-node

HTTP/1.1 404 Not Found

curl -i -H "Content-Type: application/json" -X POST http://localhost:4002/nodes/ -d '{"id":"my-node", "fn":"multiply","factor":10}'

curl -i -X GET http://localhost:4002/nodes/my-node

{
  "my-node": {
    "id": "my-node",
    "attrs": {
      "factor": "10"
    }
  }
}



curl -i -H "Content-Type: application/json" -X POST http://localhost:4002/nodes/ -d '{"id":"other-node", "fn":"multiply","factor":10, "sources":["my-node"]}'

curl -i -X GET http://localhost:4002/nodes


{
  "my-node": {
    "id": "my-node",
    "attrs": {
      "factor": 10
    },
    "sources": [
      "my-node"
    ]
  },
  "other-node": {
    "id": "other-node",
    "attrs": {
      "factor": 10
    },
    "sources": [
      "my-node"
    ]
  }
}

curl -i -H "Content-Type: application/json" -X POST http://localhost:4002/nodes/my-node/message -d '{"value":100}'

curl -i -X GET http://localhost:4002/nodes

{
  "my-node": {
    "id": "my-node",
    "message": {
      "value": 100
    },
    "attrs": {
      "factor": 10
    }
  },
  "other-node": {
    "id": "other-node",
    "message": {
      "value": 100
    },
    "attrs": {
      "factor": 10
    },
    "sources": [
      "my-node"
    ]
  }
}



curl -i -X DELETE http://localhost:4002/nodes/my-node

Release History

  • 23/11/2013 0.0.1 Initial release

License

Copyright (c) 2013 Simon Swain Licensed under the MIT license.

lancaster's People

Contributors

modusoperator avatar simonswain avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.