-
Notifications
You must be signed in to change notification settings - Fork 261
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
Introduce AccountsFileProvider #334
Conversation
3c0f878
to
72750b8
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #334 +/- ##
=======================================
Coverage 81.8% 81.9%
=======================================
Files 841 841
Lines 228267 228272 +5
=======================================
+ Hits 186924 186984 +60
+ Misses 41343 41288 -55 |
72750b8
to
b9eedf7
Compare
b9eedf7
to
14a2d10
Compare
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.
Hopefully the generic AccountsFileProvider
doesn't get too unruly. I can't think of a better way to handle this though.
37569af
to
9becc72
Compare
be0be12
to
82260e6
Compare
Rebased on top of #434 |
82260e6
to
6ebec49
Compare
Rebased on top of master that includes #434 |
Code looks good to me. Adding @jeffwashington to review as well. Jeff, wdyt of this solution? |
I'm struggling with the language feature of traits applied to this. I'm not immediately thinking, "Yes, this is the right way to do it." I would mr. language, @brooksprumo to have ideas. |
Here're some exam examples of how this PR is used: |
I guess alternatives are:
|
I start feeling enum might be the right way to go. My initial thought was that constructor functions usually don't take Let's try to imagine how this would apply to the entire code base. In production, AccountsDb instance is created via
enum-based approachFor enum-based approach, the above accounts_file_type can be replaced by the provider enum. So it will be:
And we will likely copy this field to AccountsDb. Then, for all functions that need to create a new accounts-file, we will need to pass-around the trait-based approachFor trait-based approach, I feel we will need to match the enum at some point as we can't dynamically determine the type:
A slight up-side for this is that, after the top-level call. Subsequent call will directly obtain the correct provider type. The other way is to have Another way to achieve the trait-based approach is to have AccountsDb take a generic like this:
But again I feel this might not be the right way. 2 different creation fnsAssuming two creation fns share the same API, then I think AccountsDbConfig will have one field that is the instance of the creation function:
I feel this approach works similarly to the enum-based approach, but the enum-based approach might better organize things than this. a creation fn that uses state from AccountsDb to know which type of new storage to create?I feel this is a mixed approach of enum + trait. As it requires passing an argument, it also performs a match. But I feel enum-based and trait-based organize better. wdyt @jeffwashington, @brooksprumo |
To cast my own vote, here're the two solutions that I prefer: Pass-around ProviderEnum from AccountsDbConfig
So all functions that create a writable-accounts-file will take an enum instance of accounts-file-provider. Use match on top-level calls w/ generic for creating accounts-fileOnly on top-level calls. Subsequent calls should already have the right provider type
|
Created an enum-based PR #457: |
i think we will go with enum |
Problem
Currently, all existing code paths for creating a new writable AccountsFile
are hard-coded to create an AppendVec. As we introduce a new AccountsFile
format, we will need a more programmatic way to create writable AccountsFiles
using a different format.
Summary of Changes
This PR introduces AccountsFileProvider trait, which allows both AppendVec
and TieredStorage to provide their implementations to create a new AccountsFile.
This will later allow tests and the production code-path to switch between different
formats programmatically.
For existing places where AppendVec is created, this PR simply replaces them by
AppendVecProvider. Will create follow-up PRs that change them to use generic.