-
-
Notifications
You must be signed in to change notification settings - Fork 420
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
Default Instance Storage #279
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feels like time to finally add some configuration. This makes it easy to setup the default instance per thread using Flipper.configure.
This feels better than defaulting to memory adapter which feels unexpected. I'd rather see an error pop early with instructions on how to fix.
Default feels like enough and instance felt repetitive since the return value is a DSL instance.
The reason is that module_function isn't delegating the def_delegators methods and I don't want to figure it out right now. Happy to change it if someone looks into it at some point.
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a tidy little spot to configure the default flipper instance. This has long been a thing people have to think about to use flipper. Rarely do people use multiple flipper instances in the same app, and if they want to they still can, but at least now it is wrapped up for most people.
default
is configured with a block. This makes it so it can either return a single instance no matter what or generate an instance safe for a thread, if necessary. A top level methodFlipper.instance
exists to memoize an instance of the default per thread.Each thread should get its own flipper instance with this, which should keep things thread safe without much work. This seemed easier than synchronizing everywhere. Since Flipper::DSL instances are light, it seemed like a fine trade off. Let me know if you have any different thoughts.
All of the DSL methods (save
group
which is already top level inFlipper
module) are now delegated toFlipper.instance
. This makes it so instead of doing:You can do:
...which is shorter and easier to remember. The list of methods delegated at this time is here.
I'll let this sit for a day or so. Please drop any comments. If I've already merged, feel free to continue to drop comments and I'll follow up with subsequent PRs to address.
fixes #243
xref #261