Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 98e9d662780768615e4ece94692759ce38d65080 0 parents
@DukeyToo DukeyToo authored
2  .gitignore
@@ -0,0 +1,2 @@
+
+/node_modules
21 LICENSE.txt
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2012 Perfect API LLC
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
36 bin/proxy.js
@@ -0,0 +1,36 @@
+#!/usr/bin/env node
+
+var perfectapi = require('perfectapi');
+//var perfectapi = require('../../perfectapi/api.js')
+var path = require('path');
+var main = require('../lib/main.js');
+
+var configPath = path.resolve(__dirname, '..', 'perfectapi.json');
+var parser = new perfectapi.Parser();
+var pollInterval = 60 * 1000;
+
+//handle the commands
+parser.on("getLoad", function(config, callback) {
+ main.getLoad(config, function(err, result) {
+ callback(err, result);
+ });
+});
+
+parser.on("getCulprit", function(config, callback) {
+ main.getCulprit(db, config, function(err, result) {
+ callback(err, result);
+ });
+});
+
+module.exports = parser.parse(configPath);
+
+perfectapi.proxy('http://localhost/paas/registry', function(err, registry) {
+ //now we have a reference to the registry running on the same machine
+
+ setInterval(function() {
+ var config = {}
+ registry.listServices(config, function(err, result) {
+ //todo: stuff
+ })
+ }, pollInterval);
+});
10 lib/main.js
@@ -0,0 +1,10 @@
+var async = require('async');
+
+exports.getLoad = function(db, config, callback) {
+
+}
+
+exports.getCulprit = function(db, config, callback) {
+
+}
+
23 package.json
@@ -0,0 +1,23 @@
+{ "name": "paas-machine-proxy"
+, "version": "0.0.1"
+ ,"description": "Per-machine Reverse Proxy for perfectapi self-hosted PaaS solution"
+, "author": {"name": "Steve Campbell", "email": "steve@perfectapi.com" }
+ ,"keywords": "paas,reverse proxy,service"
+ ,"homepage": "http://blog.perfectapi.com/2012/writing-a-paas-using-node.js-in-1-week-monday/"
+ ,"bugs": {"url": "https://github.com/perfectapi/node-paas-machine-proxy/issues", "email": "paas@perfectapi.com" }
+ ,"main": "./bin/proxy.js"
+ ,"bin": "./bin/proxy.js"
+, "engines": {
+ "node" : ">=0.6.5"
+ }
+, "dependencies": {
+ "perfectapi": ">=0.0.14",
+ "redis": ">=0.7.1",
+ "async": ">=0.1.15"
+ }
+, "repository" :
+ {
+ "type" : "git",
+ "url" : "git://github.com/perfectapi/node-paas-machine-proxy.git"
+ }
+}
17 perfectapi.json
@@ -0,0 +1,17 @@
+{ "exports": "reverseProxy",
+ "signature": [
+ {
+ "name": "getLoad",
+ "synopsis": "Retrieves the load index of the server, 1.0 is at capacity",
+ "description": "",
+ "verb": "GET"
+ },
+ {
+ "name": "getCulprit",
+ "synopsis": "Returns a reference to the instance that is hogging most of the capacity of the server",
+ "description": "",
+ "verb": "GET"
+ }
+ ],
+ "path": "paas/proxy"
+}
3  readme.md
@@ -0,0 +1,3 @@
+# What is this?
+
+This is a component of a self-hosted PaaS solution for PerfectAPI services. It provides a per-machine reverse proxy, so that higher level load balancers and reverse proxies can be simplified to deal only with balancing across hosts, not services.
Please sign in to comment.
Something went wrong with that request. Please try again.