Skip to content

Commit

Permalink
Rev bpmux dep and re-emit events
Browse files Browse the repository at this point in the history
  • Loading branch information
davedoesdev committed Jan 23, 2017
1 parent 078239f commit 53ec030
Show file tree
Hide file tree
Showing 15 changed files with 1,536 additions and 1,052 deletions.
94 changes: 87 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ Coveralls page is [here](https://coveralls.io/r/davedoesdev/mqlobber).
- <a name="toc_mqlobberclientprototypepublishtopic-options-cb"></a>[MQlobberClient.prototype.publish](#mqlobberclientprototypepublishtopic-options-cb)
- <a name="toc_mqlobberclienteventshandshakehandshake_data"></a><a name="toc_mqlobberclientevents"></a>[MQlobberClient.events.handshake](#mqlobberclienteventshandshakehandshake_data)
- <a name="toc_mqlobberclienteventsbackoff"></a>[MQlobberClient.events.backoff](#mqlobberclienteventsbackoff)
- <a name="toc_mqlobberclienteventsdrain"></a>[MQlobberClient.events.drain](#mqlobberclienteventsdrain)
- <a name="toc_mqlobberclienteventsfull"></a>[MQlobberClient.events.full](#mqlobberclienteventsfull)
- <a name="toc_mqlobberclienteventsremovedduplex"></a>[MQlobberClient.events.removed](#mqlobberclienteventsremovedduplex)
- <a name="toc_mqlobberclienteventserrorerr-obj"></a>[MQlobberClient.events.error](#mqlobberclienteventserrorerr-obj)
- <a name="toc_mqlobberclienteventswarningerr-obj"></a>[MQlobberClient.events.warning](#mqlobberclienteventswarningerr-obj)
- <a name="toc_mqlobberserverfsq-stream-options"></a>[MQlobberServer](#mqlobberserverfsq-stream-options)
Expand All @@ -194,6 +197,9 @@ Coveralls page is [here](https://coveralls.io/r/davedoesdev/mqlobber).
- <a name="toc_mqlobberservereventsmessagestream-info-multiplex-done"></a>[MQlobberServer.events.message](#mqlobberservereventsmessagestream-info-multiplex-done)
- <a name="toc_mqlobberservereventshandshakehandshake_data-delay_handshake"></a>[MQlobberServer.events.handshake](#mqlobberservereventshandshakehandshake_data-delay_handshake)
- <a name="toc_mqlobberservereventsbackoff"></a>[MQlobberServer.events.backoff](#mqlobberservereventsbackoff)
- <a name="toc_mqlobberservereventsdrain"></a>[MQlobberServer.events.drain](#mqlobberservereventsdrain)
- <a name="toc_mqlobberservereventsfull"></a>[MQlobberServer.events.full](#mqlobberservereventsfull)
- <a name="toc_mqlobberservereventsremovedduplex"></a>[MQlobberServer.events.removed](#mqlobberservereventsremovedduplex)
- <a name="toc_mqlobberservereventsackinfo"></a>[MQlobberServer.events.ack](#mqlobberservereventsackinfo)
- <a name="toc_mqlobberservereventserrorerr-obj"></a>[MQlobberServer.events.error](#mqlobberservereventserrorerr-obj)
- <a name="toc_mqlobberservereventswarningerr-obj"></a>[MQlobberServer.events.warning](#mqlobberservereventswarningerr-obj)
Expand All @@ -220,6 +226,11 @@ server). It also supports the following additional property:
emit this as a [`handshake`](#mqlobberservereventshandshakehandshake_data-delay_handshake) event to its
application.


**Throws:**

- `{Error}` If an error occurs before initiating the multiplex with the server.

<sub>Go: [TOC](#tableofcontents)</sub>

<a name="mqlobberclientprototype"></a>
Expand Down Expand Up @@ -265,6 +276,11 @@ the following arguments:

- `{Object} err` If an error occurred then details of the error, otherwise `null`.


**Throws:**

- `{Error}` If an error occurs before sending the subscribe request to the server.

<sub>Go: [TOC](#tableofcontents) | [MQlobberClient.prototype](#toc_mqlobberclientprototype)</sub>

## MQlobberClient.prototype.unsubscribe([topic], [handler], [cb])
Expand All @@ -287,6 +303,11 @@ argument:

- `{Object} err` If an error occurred then details of the error, otherwise `null`.


**Throws:**

- `{Error}` If an error occurs before sending the unsubscribe request to the server.

<sub>Go: [TOC](#tableofcontents) | [MQlobberClient.prototype](#toc_mqlobberclientprototype)</sub>

## MQlobberClient.prototype.publish(topic, [options], [cb])
Expand Down Expand Up @@ -318,6 +339,10 @@ argument:

`{Writable}` Stream to which to [write](https://nodejs.org/dist/latest-v4.x/docs/api/stream.html#stream_writable_write_chunk_encoding_callback) the message's data. Make sure you [`end`](https://nodejs.org/dist/latest-v4.x/docs/api/stream.html#stream_writable_end_chunk_encoding_callback) it when you're done.

**Throws:**

- `{Error}` If an error occurs before sending the publish request to the server.

<sub>Go: [TOC](#tableofcontents) | [MQlobberClient.prototype](#toc_mqlobberclientprototype)</sub>

<a name="mqlobberclientevents"></a>
Expand All @@ -343,8 +368,35 @@ Emitted by a `MQlobberClient` object when it delays a request to the server
because the connection is at full capacity. If you want to avoid buffering
further requests, don't call [`subscribe`](#mqlobberclientprototypesubscribetopic-handler-cb),
[`unsubscribe`](#mqlobberclientprototypeunsubscribetopic-handler-cb) or
[`publish`](http://localhost:6419/#mqlobberclientprototypepublishtopic-options-cb) until the connection `Duplex` emits a
[`drain`](https://nodejs.org/dist/latest-v4.x/docs/api/stream.html#stream_event_drain) event.
[`publish`](http://localhost:6419/#mqlobberclientprototypepublishtopic-options-cb) until a [`drain`](#mqlobberclienteventsdrain) event is emitted.

<sub>Go: [TOC](#tableofcontents) | [MQlobberClient.events](#toc_mqlobberclientevents)</sub>

## MQlobberClient.events.drain()

> `drain` event
Emitted by a `MQlobberClient` object when the multiplexing layer emits a [`drain`](https://github.com/davedoesdev/bpmux#bpmuxeventsdrain) event.

<sub>Go: [TOC](#tableofcontents) | [MQlobberClient.events](#toc_mqlobberclientevents)</sub>

## MQlobberClient.events.full()

> `full` event
Emitted by a `MQlobberClient` object when the multiplexing layer emits a [`full`](https://github.com/davedoesdev/bpmux#bpmuxeventsfull) event.

<sub>Go: [TOC](#tableofcontents) | [MQlobberClient.events](#toc_mqlobberclientevents)</sub>

## MQlobberClient.events.removed(duplex)

> `removed` event
Emitted by a `MQlobberClient` object when the multiplexing layer emits a [`removed`](https://github.com/davedoesdev/bpmux#bpmuxeventsremovedduplex) event.

**Parameters:**

- `{Duplex} duplex` The multiplexed stream which has closed.

<sub>Go: [TOC](#tableofcontents) | [MQlobberClient.events](#toc_mqlobberclientevents)</sub>

Expand Down Expand Up @@ -405,6 +457,9 @@ client). It also supports the following additional property:
- `{Boolean} send_size` Whether to include message size in metadata sent to
then client. Defaults to `false`.

- `{Boolean} defer_to_final_handler` If `true` then a message stream is only
considered finished when all `MQlobberServer` objects finish processing it.

<sub>Go: [TOC](#tableofcontents)</sub>

<a name="mqlobberserverprototype"></a>
Expand Down Expand Up @@ -634,19 +689,44 @@ Emitted by a `MQlobberServer` object when it delays a message to the client
because the connection is at full capacity.

If you want to avoid buffering further messages, use a `filter` function (see
`QlobberFSQ`'s [constructor](https://github.com/davedoesdev/qlobber-fsq#qlobberfsqoptions)) to prevent messages being sent until the connection `Duplex` emits a
[`drain`](https://nodejs.org/dist/latest-v4.x/docs/api/stream.html#stream_event_drain) event. In the `filter` function, a handler owned by a `MQlobberServer`
object will have a property named `mqlobber_server` set to the `MQlobberServer`
object.
`QlobberFSQ`'s [constructor](https://github.com/davedoesdev/qlobber-fsq#qlobberfsqoptions)) to prevent messages being sent until a [`drain`](#mqlobberservereventsdrain) event is emitted. In the `filter` function, a handler owned by a `MQlobberServer` object will have a property named `mqlobber_server` set to the `MQlobberServer` object.

You can also use event listeners on [`subscribe_requested`](#mqlobberservereventssubscribe_requestedtopic-cb), [`unsubscribe_requested`](#mqlobberservereventsunsubscribe_requestedtopic-cb), [`unsubscribe_all_requested`](#mqlobberservereventsunsubscribe_all_requestedcb) and [`publish_requested`](#mqlobberservereventspublish_requestedtopic-stream-options-cb) to prevent responses being
sent to the client until the connection emits a `drain` event.
sent to the client a `drain` event is emitted.

Depending on your application, you might also terminate the connection if it
can't keep up.

<sub>Go: [TOC](#tableofcontents) | [MQlobberServer.events](#toc_mqlobberserverevents)</sub>

## MQlobberServer.events.drain()

> `drain` event
Emitted by a `MQlobberServer` object when the multiplexing layer emits a [`drain`](https://github.com/davedoesdev/bpmux#bpmuxeventsdrain) event.

<sub>Go: [TOC](#tableofcontents) | [MQlobberServer.events](#toc_mqlobberserverevents)</sub>

## MQlobberServer.events.full()

> `full` event
Emitted by a `MQlobberServer` object when the multiplexing layer emits a [`full`](https://github.com/davedoesdev/bpmux#bpmuxeventsfull) event.

<sub>Go: [TOC](#tableofcontents) | [MQlobberServer.events](#toc_mqlobberserverevents)</sub>

## MQlobberServer.events.removed(duplex)

> `removed` event
Emitted by a `MQlobberServer` object when the multiplexing layer emits a [`removed`](https://github.com/davedoesdev/bpmux#bpmuxeventsremovedduplex) event.

**Parameters:**

- `{Duplex} duplex` The multiplexed stream which has closed.

<sub>Go: [TOC](#tableofcontents) | [MQlobberServer.events](#toc_mqlobberserverevents)</sub>

## MQlobberServer.events.ack(info)

> `ack` event
Expand Down
2 changes: 1 addition & 1 deletion coverage/coverage.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions coverage/lcov-report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>413/413</span>
<span class='fraction'>427/427</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
Expand All @@ -32,12 +32,12 @@ <h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>56/56</span>
<span class='fraction'>62/62</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>412/412</span>
<span class='fraction'>426/426</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -75,13 +75,13 @@ <h1>
<td class="file high" data-value="mqlobber/lib/"><a href="mqlobber/lib/index.html">mqlobber/lib/</a></td>
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
<td data-value="100" class="pct high">100%</td>
<td data-value="411" class="abs high">411/411</td>
<td data-value="425" class="abs high">425/425</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="220" class="abs high">220/220</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="56" class="abs high">56/56</td>
<td data-value="62" class="abs high">62/62</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="410" class="abs high">410/410</td>
<td data-value="424" class="abs high">424/424</td>
</tr>

</tbody>
Expand All @@ -90,7 +90,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 16 2017 22:24:32 GMT+0000 (GMT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 23 2017 21:17:49 GMT+0000 (GMT)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/mqlobber/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 16 2017 22:24:32 GMT+0000 (GMT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 23 2017 21:17:49 GMT+0000 (GMT)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion coverage/lcov-report/mqlobber/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 16 2017 22:24:32 GMT+0000 (GMT)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Jan 23 2017 21:17:49 GMT+0000 (GMT)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down

0 comments on commit 53ec030

Please sign in to comment.