Skip to content

Commit

Permalink
Reorganized code, added code docs and optimized readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias Peter authored and Mathias Peter committed Jan 20, 2015
1 parent 944a701 commit d55d641
Show file tree
Hide file tree
Showing 10 changed files with 960 additions and 359 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = (grunt) ->
pckg:
options:
globals:
version: "0.0.4"
version: "<%= pkg.version %>"

prefix: "@@"
suffix: ''
Expand Down
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Build Status](https://david-dm.org/mpneuried/rsmq-worker.png)](https://david-dm.org/mpneuried/rsmq-worker)
[![NPM version](https://badge.fury.io/js/rsmq-worker.png)](http://badge.fury.io/js/rsmq-worker)

RSMQ helper to simply implement a worker around the message queue.
Helper to simply implement a worker [RSMQ ( Redis Simple Message Queue )](https://github.com/smrchy/rsmq).

[![NPM](https://nodei.co/npm/rsmq-worker.png?downloads=true&stars=true)](https://nodei.co/npm/rsmq-worker/)

Expand Down Expand Up @@ -48,7 +48,7 @@ RSMQ helper to simply implement a worker around the message queue.
- **options.redis**: *( `RedisClient` optional; default = `null` )* A already existing redis client instance to use if no `rsmq` instance has been defined
- **options.redisPrefix**: *( `String` optional; default = `""` )* The redis Prefix for rsmq if no `rsmq` instance has been defined
- **options.host**: *( `String` optional; default = `"localhost"` )* Host to connect to redis if no `rsmq` or `redis` instance has been defined
- **options.host**: *( `Number` optional; default = `6379` )* Port to connect to redis if no `rsmq` or `redis` instance has been defined
- **options.port**: *( `Number` optional; default = `6379` )* Port to connect to redis if no `rsmq` or `redis` instance has been defined
- **options.options**: *( `Object` optional; default = `{}` )* Options to connect to redis if no `rsmq` or `redis` instance has been defined


Expand All @@ -72,18 +72,6 @@ If you haven't defined the config `autostart` to `true` you have to call the `.s

*( Self )*: The instance itself for chaining.

### `.del( id )`

Helper function to simply delete a message after it has been processed.

**Arguments**

* `id` : *( `String` required )*: The rsmq message id.

**Return**

*( Self )*: The instance itself for chaining.

### `.stop()`

Stop the receive interval.
Expand All @@ -105,6 +93,18 @@ Helper function to simply send a message in the configured queue.

*( Self )*: The instance itself for chaining.

### `.del( id )`

Helper function to simply delete a message after it has been processed.

**Arguments**

* `id` : *( `String` required )*: The rsmq message id.

**Return**

*( Self )*: The instance itself for chaining.

## Events

### `message`
Expand Down Expand Up @@ -222,13 +222,14 @@ This is an advanced example showing some features in action.

## Todos/Ideas

- TEST scripts ;-)
- Code method docs
- Timeout for message processing
- MORE tests!

## Release History
|Version|Date|Description|
|:--:|:--:|:--|
|0.1.1|2015-1-??|Added test scripts and optimized repository file list|
|0.1.2|2015-1-20|Reorganized code, added code docs and optimized readme|
|0.1.1|2015-1-17|Added test scripts and optimized repository file list|
|0.1.0|2015-1-16|First working and documented version
|0.0.1|2015-1-14|Initial commit|

Expand Down
141 changes: 82 additions & 59 deletions _docs/README.md.html

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions _docs/_src/example/example.coffee.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<title>example.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" media="all" href="../../doc-style.css" />
<script src="../../doc-filelist.js"></script>
<script>
var relativeDir = "../../", thisFile = "_src/example/example.coffee", defaultSidebar = true;
</script>
<script src="../../doc-script.js"></script>
</head>
<body>
<div id="sidebar_wrapper">
<div id="sidebar_switch">
<span class="tree">Files</span>
<span class="headings">Headings</span>
</div>
<div id="tree"></div>
<div id="headings">
</div>
</div>
<div id="sidebar-toggle"></div>
<div id="container"><div class="background highlight"></div>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="docs">
<h1>example.coffee</h1>
</td>
<td class="code highlight"></td>
</tr>
<tr>
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-1" id="section-1">&#182;</a>
</div>

</td>
<td class="code highlight"><div class="highlight"><pre><a class="line-num" href="#line-1" id="line-1">1</a> <span class="nv">RSMQWorker = </span><span class="nx">require</span><span class="p">(</span> <span class="s">&quot;../.&quot;</span> <span class="p">)</span>
<a class="line-num" href="#line-2" id="line-2">2</a> <span class="nv">worker = </span><span class="k">new</span> <span class="nx">RSMQWorker</span><span class="p">(</span> <span class="s">&quot;myqueue&quot;</span><span class="p">,</span> <span class="p">{</span> <span class="nv">interval: </span><span class="p">[</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span> <span class="p">]</span> <span class="p">}</span> <span class="p">)</span>
<a class="line-num" href="#line-3" id="line-3">3</a>
<a class="line-num" href="#line-4" id="line-4">4</a> <span class="nx">worker</span><span class="p">.</span><span class="nx">on</span> <span class="s">&quot;message&quot;</span><span class="p">,</span> <span class="nf">( msg, next, id )=&gt;</span>
<a class="line-num" href="#line-5" id="line-5">5</a> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span> <span class="s">&quot;RECEIVED&quot;</span><span class="p">,</span> <span class="nx">msg</span> <span class="p">)</span>
<a class="line-num" href="#line-6" id="line-6">6</a> <span class="nx">next</span><span class="p">()</span>
<a class="line-num" href="#line-7" id="line-7">7</a> <span class="k">return</span>
<a class="line-num" href="#line-8" id="line-8">8</a>
<a class="line-num" href="#line-9" id="line-9">9</a> <span class="nx">worker</span><span class="p">.</span><span class="nx">start</span><span class="p">()</span>
<a class="line-num" href="#line-10" id="line-10">10</a> </pre></div>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
55 changes: 55 additions & 0 deletions _docs/_src/example/sender.coffee.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html>
<head>
<title>sender.coffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" media="all" href="../../doc-style.css" />
<script src="../../doc-filelist.js"></script>
<script>
var relativeDir = "../../", thisFile = "_src/example/sender.coffee", defaultSidebar = true;
</script>
<script src="../../doc-script.js"></script>
</head>
<body>
<div id="sidebar_wrapper">
<div id="sidebar_switch">
<span class="tree">Files</span>
<span class="headings">Headings</span>
</div>
<div id="tree"></div>
<div id="headings">
</div>
</div>
<div id="sidebar-toggle"></div>
<div id="container"><div class="background highlight"></div>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="docs">
<h1>sender.coffee</h1>
</td>
<td class="code highlight"></td>
</tr>
<tr>
<td class="docs">
<div class="pilwrap">
<a class="pilcrow" href="#section-1" id="section-1">&#182;</a>
</div>

</td>
<td class="code highlight"><div class="highlight"><pre><a class="line-num" href="#line-1" id="line-1">1</a> <span class="nv">RSMQWorker = </span><span class="nx">require</span><span class="p">(</span> <span class="s">&quot;../.&quot;</span> <span class="p">)</span>
<a class="line-num" href="#line-2" id="line-2">2</a> <span class="nv">worker = </span><span class="k">new</span> <span class="nx">RSMQWorker</span><span class="p">(</span> <span class="s">&quot;myqueue&quot;</span><span class="p">,</span> <span class="nv">autostart: </span><span class="kc">false</span> <span class="p">)</span>
<a class="line-num" href="#line-3" id="line-3">3</a>
<a class="line-num" href="#line-4" id="line-4">4</a> <span class="nx">worker</span><span class="p">.</span><span class="nx">on</span> <span class="s">&quot;ready&quot;</span><span class="p">,</span> <span class="o">=&gt;</span>
<a class="line-num" href="#line-5" id="line-5">5</a> <span class="k">for</span> <span class="nx">msg</span> <span class="k">in</span> <span class="s">&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;</span><span class="p">.</span><span class="nx">split</span><span class="p">(</span> <span class="s">&quot;&quot;</span> <span class="p">)</span>
<a class="line-num" href="#line-6" id="line-6">6</a> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span> <span class="s">&quot;SEND&quot;</span><span class="p">,</span> <span class="nx">msg</span> <span class="p">)</span>
<a class="line-num" href="#line-7" id="line-7">7</a> <span class="nx">worker</span><span class="p">.</span><span class="nx">send</span><span class="p">(</span> <span class="nx">msg</span> <span class="p">)</span>
<a class="line-num" href="#line-8" id="line-8">8</a> <span class="k">return</span>
<a class="line-num" href="#line-9" id="line-9">9</a> </pre></div>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
Loading

0 comments on commit d55d641

Please sign in to comment.