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

Refactor plugin #225

Merged
merged 14 commits into from
Jul 1, 2023
Merged

Refactor plugin #225

merged 14 commits into from
Jul 1, 2023

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Jun 27, 2023

Refactoring Plugin.

Trying to use more meaningful parameter names. And also kind of decoupling avvio/boot from plugin.

I decoupled plugin from boot/avvio and added a new Error AVV_ERR_PLUGIN_EXEC_TIMEOUT

loadPlugin is now a method of boot/avvio.

Checklist

@@ -31,12 +32,32 @@ function loadPlugin (instance, plugin, callback) {
// place the plugin at the top of _current
instance._current.unshift(plugin)

plugin.exec((last && last.server) || instance._server, (err) => {
if (instance._error && !plugin.isAfter) {
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 moved this from plugin.exec, as it seemed odd to me, that we could do this already in the loadPlugin function, and decouple so Plugin from Avvio.

lib/plugin.js Outdated
const err = new AVV_ERR_READY_TIMEOUT(name)
err.fn = func
done(err)
const readyTimeoutErr = new AVV_ERR_READY_TIMEOUT(name)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldnt it make more sense to create and use a AVV_ERR_PLUGIN_EXEC_TIMEOUT?

Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Imho there are two timeouts. One is that the plugin loaded too long. For this I throw AVV_ERR_PLUGIN_EXEC_TIMEOUT. The other timeout is when the overall loading takes simply too long, e.g. all plugins take together more time than the avvio is allowed to.

I think it should be differenciated. But I am willing to revert that change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@metcoder95

We should discuss here if the new Error makes more sense.

lib/plugin.js Show resolved Hide resolved
lib/plugin.js Outdated Show resolved Hide resolved
@Uzlopak
Copy link
Contributor Author

Uzlopak commented Jun 27, 2023

@mcollina
@Eomm
@climba03003

I have some question and ask for feedback ;)

@Uzlopak Uzlopak requested review from mcollina, Eomm and climba03003 June 28, 2023 10:31
@Uzlopak
Copy link
Contributor Author

Uzlopak commented Jun 29, 2023

@metcoder95
@jsumners

Do you have maybe some input regarding my questions?

@Uzlopak Uzlopak marked this pull request as ready for review June 30, 2023 00:30
Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

Seeing the changes, I'm starting to think if it would be worth it to explore a further change to the data structure that manages the plugins. Currently is a queue (that slightly mimics a linked list in the sense that they are more or less aware of each other).

Instead, if we can successfully shift it to a tree, we would be able to enable several functionalities (like parallel loading) by identifying plugin dependants to locate nodes that can be loaded in parallel (does not depend on other plugins, a leaf node basically).

Just thinking out loud, but is it something we can explore further in another PR?

lib/errors.js Show resolved Hide resolved
@jsumners
Copy link
Member

@metcoder95 @jsumners

Do you have maybe some input regarding my questions?

I do not have the mental capacity right now to study this codebase and provide useful feedback.

boot.js Outdated Show resolved Hide resolved
boot.js Outdated Show resolved Hide resolved
@Uzlopak
Copy link
Contributor Author

Uzlopak commented Jun 30, 2023

@jsumners
Thanks anyway :)

@metcoder95
This could be possible. But I am currently thinking about how I could increase the code coverage of plugin.js as it is still at poor 87%. ;D

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@Uzlopak Uzlopak merged commit a5b5ba9 into master Jul 1, 2023
@Uzlopak Uzlopak deleted the refactor-plugin branch July 1, 2023 08:37
@Uzlopak
Copy link
Contributor Author

Uzlopak commented Jul 1, 2023

Thank you. I will hopefully provide more PRs today. ;)

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

Successfully merging this pull request may close these issues.

4 participants