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

Expose current Aedes version, used in aedes-stats #294

Merged
merged 4 commits into from
Aug 13, 2019

Conversation

gnought
Copy link
Collaborator

@gnought gnought commented Aug 11, 2019

No description provided.

Copy link
Collaborator

@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.

Can you add it to the prototype as well? aedes-stats should receive an instance of Aedes.

@mcollina
Copy link
Collaborator

Also, can you add a unit test?

@gnought
Copy link
Collaborator Author

gnought commented Aug 11, 2019

I think the unit test should be in aedes-stats project.
I will add the code
doPub('version', aedesInstance.constructor.version)
in aedes-stats iterate() function https://github.com/mcollina/aedes-stats/blob/master/stats.js#L52

@mcollina
Copy link
Collaborator

mcollina commented Aug 11, 2019 via email

@gnought
Copy link
Collaborator Author

gnought commented Aug 11, 2019

Add to prototype could be, but it will require an extra memory for storing version in each instance, and it is not useful for user except aedes-stats.
Version won’t change in each instance, except a user packs two aedes package. In this case he still can get different version using aedes.constructor.version, right?

@gnought
Copy link
Collaborator Author

gnought commented Aug 11, 2019

My idea is also be memory-wise

@mcollina
Copy link
Collaborator

The following will not cause any addition memory allocation:

Aedes.prototype.version =  require('./package').version

The reason for that is that it will stick the value on the prototype itself. Instances will look the value there, much like any additional function.

test/meta.js Outdated

var broker = aedes()
if (broker.version === undefined) {
t.fail('version undefined')
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you check if the content is the same of package.json?

Copy link
Collaborator

@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

@mcollina mcollina merged commit a1f9a4b into moscajs:master Aug 13, 2019
@gnought gnought deleted the feature/aedes_stats_metrics branch August 13, 2019 15:48
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.

2 participants