Skip to content

Commit

Permalink
api: simple ping route to probe if the server is up
Browse files Browse the repository at this point in the history
just returns a 200 status code if the server is up

Semver: minor
  • Loading branch information
esatterwhite committed Dec 1, 2018
1 parent 211bb5d commit 1033b9e
Show file tree
Hide file tree
Showing 52 changed files with 182 additions and 60 deletions.
23 changes: 23 additions & 0 deletions docs/api/api_data.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
define({ "api": [
{
"description": "<p>returns a 200 status if the server is up</p>",
"group": "ping",
"name": "get_ping",
"type": "get",
"url": "/ping",
"title": "",
"version": "8.0.0",
"examples": [
{
"title": "curl:",
"content": "curl -i -XGET http://localhost:3000/ping",
"type": "curl"
},
{
"title": "Node.js:",
"content": "const http = require('http')\nhttp.get('http://localhost:3000/ping, (err, res) => {\n console.log(res.statusCode);\n})",
"type": "js"
}
],
"filename": "lib/server/api/get_ping.js",
"groupTitle": "ping"
},
{
"description": "<p>Create a new time on the cluster</p>",
"group": "timer",
Expand Down
23 changes: 23 additions & 0 deletions docs/api/api_data.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
[
{
"description": "<p>returns a 200 status if the server is up</p>",
"group": "ping",
"name": "get_ping",
"type": "get",
"url": "/ping",
"title": "",
"version": "8.0.0",
"examples": [
{
"title": "curl:",
"content": "curl -i -XGET http://localhost:3000/ping",
"type": "curl"
},
{
"title": "Node.js:",
"content": "const http = require('http')\nhttp.get('http://localhost:3000/ping, (err, res) => {\n console.log(res.statusCode);\n})",
"type": "js"
}
],
"filename": "lib/server/api/get_ping.js",
"groupTitle": "ping"
},
{
"description": "<p>Create a new time on the cluster</p>",
"group": "timer",
Expand Down
2 changes: 1 addition & 1 deletion docs/api/api_project.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ define({
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2018-11-30T21:51:17.815Z",
"time": "2018-11-30T22:14:26.485Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/api/api_project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"apidoc": "0.3.0",
"generator": {
"name": "apidoc",
"time": "2018-11-30T21:51:17.815Z",
"time": "2018-11-30T22:14:26.485Z",
"url": "http://apidocjs.com",
"version": "0.17.7"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/classes.list.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
8 changes: 4 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@


<section class="readme-section">
<article><p><img src="https://github.com/esatterwhite/skyring/raw/master/assets/skyring.png" alt="skyring"></p>
<article><p><img src="https://github.com/esatterwhite/skyring/raw/master/assets/skyring-inverted.png" alt="skyring"></p>
<p><a href="skyring"><img src="https://img.shields.io/travis/esatterwhite/skyring/master.svg?style=flat-square" alt="Travis branch"></a>
<a href="https://www.npmjs.com/package/skyring"><img src="https://img.shields.io/npm/v/skyring.svg?style=flat-square" alt="npm"></a>
<a href="https://github.com/esatterwhite/skyring"><img src="https://img.shields.io/npm/l/skyring.svg?style=flat-square" alt="npm"></a>
Expand All @@ -120,7 +120,7 @@
</ul>
<h1>Skyring</h1><p>A distributed reliable timer service providing <code>setTimeout</code> functionality in a distributed fashion.
<code>Skyring</code> servers are clustered into a <em>hashring</em> using consistent hashing to partition timers to specific nodes in the ring. Skyring exposes a simple HTTP API that allows to you create and cancel timers. Timer execution comes in to the form of an HTTP webhook ( more transports to come )</p>
<h1>Architecture Overview</h1><p><img src="https://raw.githubusercontent.com/esatterwhite/skyring/master/assets/skyring-arch.png" width="100%" max-width="800px"></p>
<h1>Architecture Overview</h1><p><img src="https://raw.githubusercontent.com/esatterwhite/skyring/master/assets/skyring-arch-inverted.png" width="100%" max-width="800px"></p>
<h1>Install</h1><pre class="prettyprint source"><code>npm install -s skyring</code></pre><h2>Run A Local Cluster</h2><h3>Start a nats instance</h3><p>Download the <a href="https://github.com/nats-io/gnatsd/releases">nats binary</a> and start it using the defaults</p>
<pre class="prettyprint source lang-bash"><code>$ gnats -D -V</code></pre><p>To verify that it is working, you can <code>telnet</code> directly to the server and ping it.</p>
<pre class="prettyprint source lang-bash"><code>$ telnet localhost 4222
Expand Down Expand Up @@ -274,7 +274,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down Expand Up @@ -365,4 +365,4 @@ <h4 class="modal-title">Search results</h4>


</body>
</html>
</html>
2 changes: 1 addition & 1 deletion docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/lib_json.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/lib_nats.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
3 changes: 2 additions & 1 deletion docs/lib_server_index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ <h1 class="page-title">Source: lib/server/index.js</h1>
, item.method
, item.handler
);
debug('loaded: %s %s', item.method, item.path)

item.middleware &amp;&amp; route.before( item.middleware );
}
Expand Down Expand Up @@ -328,7 +329,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/lib_server_mock.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/lib_server_node.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/lib_server_request.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/lib_server_response.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/lib_server_route.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/lib_server_router.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
4 changes: 2 additions & 2 deletions docs/lib_timer.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ <h1 class="page-title">Source: lib/timer.js</h1>
cancel(id, cb = noop) {
this[kRemove](id, (err) => {
if (err) return cb(err)
cb()
this.nats.publish('skyring:events', JSON.stringify({
type: EVENT_STATUS.CANCELLED
, timer: id
, node: this[kNode]
}))
cb()
})
}

Expand Down Expand Up @@ -643,7 +643,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/lib_transports_callback.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
16 changes: 8 additions & 8 deletions docs/lib_transports_http.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ <h1 class="page-title">Source: lib/transports/http.js</h1>
*/

const STATUS_CODES = require('http').STATUS_CODES
, method_exp = /^(post|put|patch|delete|get|options|head)$/i
, request = require('request')
, needle = require('needle')
, debug = require('debug')('skyring:transport:http')
, method_exp = /^(post|put|patch|delete|get|options|head)$/i
;

/**
Expand All @@ -123,13 +123,13 @@ <h1 class="page-title">Source: lib/transports/http.js</h1>
module.exports = function httpTransport( method, url, payload, id, cache ) {
const isJSON = typeof payload === 'object'
, _method = method.toLowerCase()
, data = payload || ''
, options = {
body: payload || ""
, json: isJSON
};
json: isJSON
};


if( method_exp.test(method) &amp;&amp; typeof request[_method] !== 'function' ) {
if( method_exp.test(method) &amp;&amp; typeof needle[_method] !== 'function' ) {
const t = cache.get(id);
t &amp;&amp; clearTimeout(t.timer);
cache.failure(id, err);
Expand All @@ -138,7 +138,7 @@ <h1 class="page-title">Source: lib/transports/http.js</h1>
}

debug('executing http transport %s', id, method);
request[_method](url, options, (err, res, body) => {
needle(_method, url, data, options, (err, res, body) => {
if(err){
debug('timer err', err);
return cache.failure(id, err);
Expand Down Expand Up @@ -200,7 +200,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/lib_transports_index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-keef.html
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-skyring.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-skyring_conf.html
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-skyring_lib_json.html
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-skyring_lib_nats.html
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:16-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-skyring_lib_server.html
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:17-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-skyring_lib_server_mock.Request.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:17-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-skyring_lib_server_mock.Response.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:17-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/module-skyring_lib_server_mock.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ <h4 class="modal-title">Search results</h4>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>

on 2018-11-30T16:51:17-05:00
on 2018-11-30T17:14:25-05:00

using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
Expand Down
Loading

0 comments on commit 1033b9e

Please sign in to comment.