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

Refactors code to support inheritance #198

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

anuragagarwal561994
Copy link

@anuragagarwal561994 anuragagarwal561994 commented Nov 30, 2019

At present everywhere there are checks for whether the queue is bull or not based on which the functionalities differ.

In this PR, this task have been properly handled by using classes and inheritance where by which all the bee related logic goes in bee.js and all the bull related logic in respective bull.js.

If another queue has to be integrated in future, it will be so much easier to just write another implementation which implementation details which affecting the core functionalities of the UI.

This makes the code more concise, easy to understand and extendable without extra if else conditions.

Three classes are mainly used:

  1. Queue: which holds the actual queue within it and provides a common interface for the application to react on function calls.
  2. Job: acts as an adapter for jobs for different queue implementation.
  3. JobData: represents not the actual job object but just the data that can be exposed to UI, JSON or anywhere else.

Copy link
Member

@skeggse skeggse left a comment

Choose a reason for hiding this comment

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

Looks like an awesome refactor to me!

I didn't filter my suggestions as well as I could have based on existing code vs new/refactored code; feel free to dismiss suggestions if you think they're out of scope.

How did you test these changes/can you describe the potential risks?

src/server/queue/bee.js Outdated Show resolved Hide resolved
src/server/queue/bee.js Outdated Show resolved Hide resolved
}
}

async remove() {
Copy link
Member

Choose a reason for hiding this comment

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

Can we have these abstract methods throw a not implemented exception? This would both make it clear that these should be overridden, and avoid weird cases down the road where we instantiate a Job but avoid the constructor.

Copy link
Author

Choose a reason for hiding this comment

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

Done, just check once. Didn't use a message because the stacktrace should already cover the method name from where the error originated.

src/server/views/api/bulkAction.js Outdated Show resolved Hide resolved
src/server/views/api/performAction.js Outdated Show resolved Hide resolved
src/server/views/dashboard/jobDetails.js Outdated Show resolved Hide resolved
src/server/views/dashboard/queueJobsByState.js Outdated Show resolved Hide resolved
src/server/views/helpers/queueHelpers.js Outdated Show resolved Hide resolved
src/server/views/api/performAction.js Outdated Show resolved Hide resolved
src/server/views/api/bulkAction.js Outdated Show resolved Hide resolved
Co-Authored-By: Eli Skeggs <skeggse@users.noreply.github.com>
@anuragagarwal561994
Copy link
Author

@skeggse Just wanted to confirm why have return void res.**json type changes have been added?

@anuragagarwal561994
Copy link
Author

@skeggse A thorough testing is still required, I did testing with just bull queue of some of the basic functionalities that I was using. I thought to first get a review done before we can move onto complete testing again together.

There should not be any potential risks associated as such, in this code refactor I carefully converted all the if and else statements to different classes. Not sure if I understood your statement here correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants