-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add each_key support to transformers #171
Conversation
c05da08
to
dc5dd75
Compare
dc5dd75
to
7e19f84
Compare
@brutuscat thanks for this, I'll check it out over the weekend! |
I am inclined towards only supporting This will work for all the What do you reckon? |
2c68c93
to
41b74eb
Compare
@asppsa something like what I just did? I move the compilation into the built transformer class, so it can add the Then it is as you said, either supports it or not based on a rule set in the |
cbcec52
to
d2cf69a
Compare
d2cf69a
to
0e56b4f
Compare
@asppsa not sure why mongodb specs are failing... |
I reverted my changes to bump the supported ruby version (already some active-support gems, e.g. rails stuff, are using 2.3) given that for some reason kyotocabinet-ruby-reanimated does not compile in ruby 2.7. See https://travis-ci.org/moneta-rb/moneta/jobs/643129451
|
b034c23
to
781c4c9
Compare
@brutuscat I'll open a separate PR for the Ruby version switch-over. If kyoto cabinet doesn't work any more, we can mark it as unsupported in 2.7+ |
@asppsa thx. Could you maybe look into what's going on with the MongoDB specs? |
Sorry it took me so long to check this. The issue with the MongoDB specs appears to be that they are all using the |
@asppsa Moped seems to have been forgotten... Since Mongo v3
And in their code you see: def create(key, options = {})
spec = options.merge(ns: namespace, key: key)
spec[:name] ||= key.to_a.join("_")
database.session.with(write: { w: 1 }) do |_s|
_s[:"system.indexes"].insert(spec)
end
end I will add a warning as it was done before for MongoDB version < 2.2. |
@asppsa I need more help with the specs :( |
2c50456
to
1b02c98
Compare
.travis.yml
Outdated
@@ -16,17 +16,15 @@ services: | |||
- memcached | |||
- mongodb | |||
- postgresql | |||
- couchdb |
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.
The issue with this approach is it reverts back to CouchDB 1.6, when the current version is now 3.0 ... at least it works though!
I'll see if I can resolve this in another way, but this is a good backup if not.
Firstly, a huge thank you for all your work here, and a big apology from me that I've been unable to take a look at this sooner. What I would really love is if we are able to split out some of the things that are going on in this PR into separate PRs. In particular the Mongo and Couch stuff should probably be separated, so we can take a look at it in isolation. There's also a couple of small things like adding The second thing is that I think we need to work out what the expected behaviour of
Your thoughts on this are appreciated. Also, I'll see if I can work out a way to get CouchDB 3.0 working ... |
Actually, the mongo issues are directly connected to the each_key stuff, are they? In that case I retract my comments about a separate mongo PR! |
@asppsa I reverted most of the changes commented here. The good thing is that now we kinda have fixes for all of them ;) |
@asppsa alright I fixed the problem of each_key with a "prefix" transformation. I added a "TEST" code in the transformers config and with that it filters the non prefixed keys. Please review. |
BTW I tested the couchdb specs in my local with the latest version and it works fine too. |
@asppsa regarding the each_key and the transformers:
I think this only makes sense for prefix. Marshal and other serialisers will fail to "load" and they we will get the exception right there. The same for the encoders I think... So I compiled a specific code for these where when these fail if won't break the chain. I also added on marshal->prefix->base64 spec that also tests the each_key with the "wrong" prefix |
I've fixed CouchDB (and also added Ruby 2.7 testing) in master now. Hopefully if you merge with master, we'll have this PR passing again. |
lib/moneta/proxy.rb
Outdated
@@ -22,7 +22,7 @@ def each_key(&block) | |||
raise NotImplementedError, "each_key is not supported on this proxy" \ | |||
unless supports? :each_key | |||
|
|||
return enum_for(:each_key) { adapter.each_key.size } unless block_given? |
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.
@asppsa so what do you think of this? Is it worth it? Most of the time the adapters will be used via some proxy (e.g. transformers) so I though it would make sense to honor the "eager size" set in the block, this is for the when someone would use the "size" method, see Object#enum_for:
If a block is given, it will be used to calculate the size of the enumerator without the need to iterate it (see Enumerator#size).
Without this I think size will be always be nil when a proxy is used.
lib/moneta/pool.rb
Outdated
raise NotImplementedError, "each_key is not supported on this proxy" \ | ||
unless supports? :each_key | ||
|
||
return enum_for(:each_key) { adapter ? adapter.each_key.size : check_out! { adapter.each_key.size } } unless block_given? |
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.
@asppsa the change in proxy forces a change here, given that the scope of the block passed in the Proxy class, is within that object, and the checkout never happens.
Retrying the build. There was a weird Ruby 2.3 failure in |
@brutuscat yes, there is unfortunately some unreliability in the test suite still. If it happens again this time, I can restart just the test(s) that fail instead of rerunning everything. Concerning the size stuff, I think it's a good addition. If the change is required in two files, so be it. |
Ok, I added the changes so to honor the adapter eager size block passed in the enum_for. Please review. |
@asppsa could u retry the dying Ruby 2.4 specs please? They seemed have timed out or something weird. I see no rspec error trace. |
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.
@brutuscat I am very happy with this now - great job! Is there anything else you wanted to add before I merge?
Not at all, LGTM. Thank you!
…On Sat, Apr 25, 2020 at 2:02 AM Alastair Pharo ***@***.***> wrote:
***@***.**** approved this pull request.
@brutuscat <https://github.com/brutuscat> I am very happy with this now -
great job! Is there anything else you wanted to add before I merge?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#171 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACJXBZOB6SZS6YPFQYQ5WTROIR73ANCNFSM4KK2RPEQ>
.
--
Mauro Asprea
E-Mail: mauroasprea@gmail.com
Mobile: +34 654297582
Keybase: https://keybase.io/brutuscat
|
Fixes #170
I added support of the key iteration feature into the Proxy and the Transformers, but with caveats because not all the transformers can be "undone" (e.g. not all of the are bijective).
I also had to hack the specs a bit to selectively disable each_key test cases where appropriate, @asppsa please revise and advice.