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

Close queue #16

Merged
merged 9 commits into from
Jul 10, 2017
Merged

Close queue #16

merged 9 commits into from
Jul 10, 2017

Conversation

delvedor
Copy link
Member

With this PR we introduce a new queue to handle the shutdown procedure, following the avvio style!

  • Use onClose to add new functions to execute.
  • Use close to start the process

Related: fastify/fastify#123

Feedbacks?

@delvedor delvedor requested a review from mcollina July 10, 2017 14:05
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.

We should also expose this if an instance is passed in.

boot.js Outdated
Boot.prototype.onClose = function (func) {
this._closeQ.push(func, err => {
if (err) this._error = err
})
Copy link
Member

Choose a reason for hiding this comment

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

I think we should call unshift() here. More or less, the latest you register a shutdown part, the sooner it will be executed. This is the inverse of the start phase.

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.

The close bit on the instance might need a unit test.
Apart from this, LGTM as semver-major.

@delvedor
Copy link
Member Author

LGTM as semver-major.

Why semver major?
I don't see a breaking change here.

@mcollina
Copy link
Member

adding the new properties to the instance is.

@delvedor
Copy link
Member Author

Ok I got you, it is not a major change for avvio itself, but it is for the apps that are using it 👍

@delvedor delvedor merged commit 52b579f into master Jul 10, 2017
@delvedor delvedor deleted the close-queue branch July 10, 2017 21:01
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.

2 participants