-
Notifications
You must be signed in to change notification settings - Fork 7
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
Memoize Hatchet::App.default_buildpack #183
Conversation
@schneems Actually, it seems that Lines 8 to 14 in a245b8c
I wasn't familiar with the "stabby lamda" operator and had missed the If that's the case, then I don't think this PR is necessary, and actually the issue in #180 was that I should have been using |
This is a stabby lambda being set to a constant. Every time it is called it will be re-evlauated.
The reason it's done like this instead of simply setting a constant is that someone might set this env var after the library is loaded, so we need it to re-evaluate the contents at runtime (instead of require time). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. My only question would be "Does this need a test to assert memorizing the value?"
expect(Hatchet::App.default_buildpack.object_id).to eq(Hatchet::App.default_buildpack.object_id)
This asserts the object is not just equal, but that it's the same object.
I'm on the fence. I think this PR is probably fine without that assertion if you want to go ahead and merge. Otherwise adding a test and merge would be good.
Thanks for working on this!
Oh sorry I follow now, the constants are being assigned an anonymous function, not a value, hence the need for I'm happy to add a test, I'll do that now. |
When you write a test please also rebase. Changelogs are merge conflict tar-pits. Let me know if you've got any tricks up your open source sleeves for better handling them. |
To improve performance and so that it still returns the correct result if called again inside an `app.deploy` block. Fixes #180.
e3d62dc
to
9e84ed5
Compare
I don't think there are many good solutions if we want to keep the changelog up to date in-between releases (which I think we do). I tend to just resolve as I go, post-review but pre-merge. Thankfully doesn't happen too often, between PRs normally being spaced out in time, and then a proportion of them being |
Thanks! |
To improve performance and so that it still returns the correct result if called again inside an
app.deploy
block.Fixes #180.