Skip to content
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

adds reenqueue by name processor #9

Merged
merged 1 commit into from
May 11, 2018

Conversation

azharkhan
Copy link
Contributor

@azharkhan azharkhan commented May 9, 2018

We need a way to process large number of deadletter events by filtering specific events.

This processor just takes an event name as a property and enqueues matching events.

@@ -56,6 +56,30 @@ describe('Deadletter processors', function() {
});
});

// eslint-disable-next-line
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long story short, it's not needed.

long story long: i thought it was jasmine so I was using fdescribe. little did I know it was mocha (also these tests are FAST)

@@ -0,0 +1,12 @@
const deadletterActions = require('./../deadletterActions');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor reenqueueAllByName

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it but seemed misleading. so I removed the All although I can be argued eitherways. don't feel too strongly about it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, its a minor comment

Copy link
Contributor

@earobinson earobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two small comments, thoughts?

@azharkhan azharkhan force-pushed the akhan/adds-reenqueue-by-eventname branch from 0800848 to 336df0e Compare May 9, 2018 21:05
@azharkhan
Copy link
Contributor Author

@earobinson - updated with less eslint

Copy link

@iain8 iain8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor nitpicking

if (event === content.event) {
return Q.when(deadletterActions.REENQUEUE_MESSAGE);
} else {
return Q.reject(new Error(`Required ${event} does not match ${message.content.event}`));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we need Q for these, should be able to use native promises

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while I agree with that and I'd use native as much as possible, but I'm not sure (maybe I'm unaware) of a Q.when() implementation in the Promise prototype.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case the parameter is just a string so Promise.resolve() could work? i find the when method mysterious indeed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since I'm not sure if a Promise.resolve would work, I'd suggest in the interest of consistency, we can go with the Q library.

however, I'm up to investigate the Promise.resolve as a separate issue so that we can switch all the deadletterProcessors to use native promises and remove the dependency on Q

#winwin

what do you think @iain8 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iain8 is correct Promise.resolve() would work, it's up to you how much you want to scout this.

Copy link
Contributor Author

@azharkhan azharkhan May 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@earobinson @iain8 - I've created an issue for this #10 in order to properly investigate this.

since the Q implementation is in step with the rest of the library, I think investigating it is definitely beneficial to reduce unnecessary dependencies, however outside of the scope of this PR.

describe('Re-Enqueue by Name Processor', function() {

it('should return with a promise containing requeue all messages action when the event name matches', function() {
const testScope = this;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't feel that aliasing the scope is necessary for using it in these tests

const Q = require('q');

module.exports = function(event, message) {
const content = JSON.parse(message.content);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parse() will throw a cheeky error if the message content isn't valid JSON, will this be handled gracefully by the library?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this context iirc the message is guaranteed to be valid json, also this would just cause our commandline app to crash

@azharkhan azharkhan merged commit b93dcb8 into master May 11, 2018
@azharkhan azharkhan deleted the akhan/adds-reenqueue-by-eventname branch May 11, 2018 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants