-
-
Notifications
You must be signed in to change notification settings - Fork 12
Implement subscription filter option #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
196fd34
3e23773
0c0d136
2df6e46
f5a1009
64b7c9e
35d9fd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,7 @@ | ||
| language: node_js | ||
| sudo: false | ||
| node_js: | ||
| - "8" | ||
| - "10" | ||
| - "12" | ||
| services: | ||
| - redis | ||
| - mongodb |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "multines", | ||
| "version": "1.0.0", | ||
| "version": "2.0.0", | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems still a bump. |
||
| "description": "Multi-process nes backend, turn nes into a fully scalable solution", | ||
| "main": "multines.js", | ||
| "scripts": { | ||
|
|
@@ -27,16 +27,16 @@ | |
| }, | ||
| "homepage": "https://github.com/mcollina/multines#readme", | ||
| "devDependencies": { | ||
| "code": "^5.2.0", | ||
| "hapi": "^17.5.0", | ||
| "lab": "^15.4.5", | ||
| "nes": "^8.1.0", | ||
| "@hapi/code": "^8.0.1", | ||
| "@hapi/hapi": "^19.0.0", | ||
| "@hapi/lab": "^22.0.3", | ||
| "@hapi/nes": "^12.0.0", | ||
| "pre-commit": "^1.1.2", | ||
| "standard": "^11.0.0" | ||
| "standard": "^14.3.1" | ||
| }, | ||
| "dependencies": { | ||
| "mqemitter": "^2.2.0", | ||
| "mqemitter-mongodb": "^3.0.2", | ||
| "mqemitter-redis": "^2.3.0" | ||
| "mqemitter": "^4.1.3", | ||
| "mqemitter-mongodb": "^7.0.0", | ||
| "mqemitter-redis": "^4.0.2" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| 'use strict' | ||
|
|
||
| const mqemitter = require('mqemitter') | ||
| const Code = require('code') | ||
| const Lab = require('lab') | ||
| const Hapi = require('hapi') | ||
| const Nes = require('nes') | ||
| const Code = require('@hapi/code') | ||
| const Lab = require('@hapi/lab') | ||
| const Hapi = require('@hapi/hapi') | ||
| const Nes = require('@hapi/nes') | ||
| const Multines = require('.') | ||
|
|
||
| const lab = exports.lab = Lab.script() | ||
|
|
@@ -21,7 +21,7 @@ function getServer (port) { | |
| return server | ||
| } | ||
|
|
||
| async function start (server, opts) { | ||
| async function start (server, opts, subOpts) { | ||
| opts = opts || {} | ||
|
|
||
| const plugin = { | ||
|
|
@@ -34,7 +34,7 @@ async function start (server, opts) { | |
|
|
||
| await server.register([Nes, plugin]) | ||
|
|
||
| server.subscriptionFar('/echo') | ||
| server.subscriptionFar('/echo', subOpts) | ||
| server.route({ | ||
| path: '/echo', | ||
| method: 'POST', | ||
|
|
@@ -185,6 +185,25 @@ experiment('nes work as normal', async () => { | |
| pubSubTest() | ||
| }) | ||
|
|
||
| experiment('with subscription filter', async () => { | ||
| let server | ||
|
|
||
| beforeEach(async () => { | ||
| server = await start(getServer(), null, { | ||
| filter: function (path, message, options) { | ||
| return true | ||
| } | ||
| }) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test where the filter function return false? Also, you'll need to add some assertions on
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the filter function returns false the test times out b/c the message doesn't arrive. I'm not sure how to assert this. I will add assertions for three params as soon as I got some time.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just create a different experiment where you do not call |
||
| }) | ||
|
|
||
| afterEach(async () => { | ||
| await server.stop() | ||
| server = null | ||
| }) | ||
|
|
||
| pubSubTest() | ||
| }) | ||
|
|
||
| experiment('with shared mqemitter', () => { | ||
| let server1 | ||
| let server2 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.