| @ -0,0 +1 @@ | |||||
| module.exports = require('../build/Release/franz'); | |||||
| @ -0,0 +1,19 @@ | |||||
| { | |||||
| "name": "franz" | |||||
| , "version": "0.0.1" | |||||
| , "description": "Network based distributed tasks" | |||||
| , "homepage": "" | |||||
| , "keywords": ["queue", "kafka", "franz"] | |||||
| , "author": "brett_langdon <brett@blangdon.com>" | |||||
| , "contributors": [ | |||||
| { "name": "brett_langdon", "email": "brett@blangdon.com" } | |||||
| ] | |||||
| , "repository":{ | |||||
| "type": "git" | |||||
| , "url": "github.com/brettlangdon/franz.git" | |||||
| } | |||||
| , "dependencies": { | |||||
| } | |||||
| , "main": "./lib/index.js" | |||||
| , "engines": { "node": ">= 0.6.0" } | |||||
| } | |||||
| @ -0,0 +1,39 @@ | |||||
| #define BUILDING_NODE_EXTENSION | |||||
| #include <node.h> | |||||
| #include "consumer.h" | |||||
| using namespace v8; | |||||
| Consumer::Consumer() {}; | |||||
| Consumer::~Consumer() {}; | |||||
| Persistent<Function> Consumer::constructor; | |||||
| void Consumer::Init() { | |||||
| // Prepare constructor template | |||||
| Local<FunctionTemplate> tpl = FunctionTemplate::New(New); | |||||
| tpl->SetClassName(String::NewSymbol("Consumer")); | |||||
| tpl->InstanceTemplate()->SetInternalFieldCount(1); | |||||
| constructor = Persistent<Function>::New(tpl->GetFunction()); | |||||
| } | |||||
| Handle<Value> Consumer::New(const Arguments& args) { | |||||
| HandleScope scope; | |||||
| Consumer* obj = new Consumer(); | |||||
| obj->Wrap(args.This()); | |||||
| return args.This(); | |||||
| } | |||||
| Handle<Value> Consumer::NewInstance(const Arguments& args) { | |||||
| HandleScope scope; | |||||
| const unsigned argc = 0; | |||||
| Handle<Value> argv[argc] = {}; | |||||
| Local<Object> instance = constructor->NewInstance(argc, argv); | |||||
| return scope.Close(instance); | |||||
| } | |||||
| @ -0,0 +1,20 @@ | |||||
| #define BUILDING_NODE_EXTENSION | |||||
| #ifndef CONSUMER_H | |||||
| #define CONSUMER_H | |||||
| #include <node.h> | |||||
| class Consumer : public node::ObjectWrap { | |||||
| public: | |||||
| static void Init(); | |||||
| static v8::Handle<v8::Value> NewInstance(const v8::Arguments& args); | |||||
| private: | |||||
| Consumer(); | |||||
| ~Consumer(); | |||||
| static v8::Persistent<v8::Function> constructor; | |||||
| static v8::Handle<v8::Value> New(const v8::Arguments& args); | |||||
| }; | |||||
| #endif | |||||
| @ -0,0 +1,29 @@ | |||||
| #define BUILDING_NODE_EXTENSION | |||||
| #include <node.h> | |||||
| #include "producer.h" | |||||
| #include "consumer.h" | |||||
| using namespace v8; | |||||
| Handle<Value> CreateProducer(const Arguments& args) { | |||||
| HandleScope scope; | |||||
| return scope.Close(Producer::NewInstance(args)); | |||||
| } | |||||
| Handle<Value> CreateConsumer(const Arguments& args) { | |||||
| HandleScope scope; | |||||
| return scope.Close(Consumer::NewInstance(args)); | |||||
| } | |||||
| void InitAll(Handle<Object> target) { | |||||
| Producer::Init(); | |||||
| Consumer::Init(); | |||||
| target->Set(String::NewSymbol("createProducer"), | |||||
| FunctionTemplate::New(CreateProducer)->GetFunction()); | |||||
| target->Set(String::NewSymbol("createConsumer"), | |||||
| FunctionTemplate::New(CreateConsumer)->GetFunction()); | |||||
| } | |||||
| NODE_MODULE(franz, InitAll) | |||||
| @ -0,0 +1,39 @@ | |||||
| #define BUILDING_NODE_EXTENSION | |||||
| #include <node.h> | |||||
| #include "producer.h" | |||||
| using namespace v8; | |||||
| Producer::Producer() {}; | |||||
| Producer::~Producer() {}; | |||||
| Persistent<Function> Producer::constructor; | |||||
| void Producer::Init() { | |||||
| // Prepare constructor template | |||||
| Local<FunctionTemplate> tpl = FunctionTemplate::New(New); | |||||
| tpl->SetClassName(String::NewSymbol("Producer")); | |||||
| tpl->InstanceTemplate()->SetInternalFieldCount(1); | |||||
| constructor = Persistent<Function>::New(tpl->GetFunction()); | |||||
| } | |||||
| Handle<Value> Producer::New(const Arguments& args) { | |||||
| HandleScope scope; | |||||
| Producer* obj = new Producer(); | |||||
| obj->Wrap(args.This()); | |||||
| return args.This(); | |||||
| } | |||||
| Handle<Value> Producer::NewInstance(const Arguments& args) { | |||||
| HandleScope scope; | |||||
| const unsigned argc = 0; | |||||
| Handle<Value> argv[argc] = {}; | |||||
| Local<Object> instance = constructor->NewInstance(argc, argv); | |||||
| return scope.Close(instance); | |||||
| } | |||||
| @ -0,0 +1,20 @@ | |||||
| #define BUILDING_NODE_EXTENSION | |||||
| #ifndef PRODUCER_H | |||||
| #define PRODUCER_H | |||||
| #include <node.h> | |||||
| class Producer : public node::ObjectWrap { | |||||
| public: | |||||
| static void Init(); | |||||
| static v8::Handle<v8::Value> NewInstance(const v8::Arguments& args); | |||||
| private: | |||||
| Producer(); | |||||
| ~Producer(); | |||||
| static v8::Persistent<v8::Function> constructor; | |||||
| static v8::Handle<v8::Value> New(const v8::Arguments& args); | |||||
| }; | |||||
| #endif | |||||
| @ -0,0 +1,15 @@ | |||||
| srcdir = '.' | |||||
| blddir = 'build' | |||||
| VERSION = '0.0.1' | |||||
| def set_options(opt): | |||||
| opt.tool_options('compiler_cxx') | |||||
| def configure(conf): | |||||
| conf.check_tool('compiler_cxx') | |||||
| conf.check_tool('node_addon') | |||||
| def build(bld): | |||||
| obj = bld.new_task_gen('cxx', 'shlib', 'node_addon') | |||||
| obj.target = 'franz' | |||||
| obj.source = ['src/consumer.cc','src/producer.cc','src/franz.cc'] | |||||