-
Notifications
You must be signed in to change notification settings - Fork 801
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
[STORE] Refactor Repository as mixin #824
Conversation
07fd27f
to
ff43886
Compare
(Following on from the discussion on #822) This looks great! :) Appreciate you going to the effort to put this together. Some questions / thoughts:
I suspect my comments above are because I don't fully understand how the different pieces interact (e.g. the |
@jits Thanks again for all your feedback! It's really nice of you to take the time to look at the pull requests : )
There are two main reasons for having the class-level settings. The first is so that you can use the DSL to set up the repository, for example: class NoteRepository
include Elasticsearch::Persistence::Repository
document_type 'note'
index_name 'notes_repo'
settings number_of_shards: 1, number_of_replicas: 0 do
mapping dynamic: 'strict' do
indexes :foo do
indexes :bar
end
indexes :baz
end
end The second is,
This is a good point. I provided the
I’d like to encourage users to create their own Repository classes so that they can be explicit about what settings they want for it. I don’t see a huge benefit of having a generic repository class, when you can just write class
I think I'll try out some changes discussed above and see how it works out. Update: |
ff43886
to
de87b40
Compare
Hi @estolfo,
Personally, I don't think it's useful to have this class level DSL to configure repositories, as I prefer the flexibility and predictability of configuring them when instantiating, at runtime. But then, others might find this DSL approach useful and simpler to manage, so I can't say definitively. I understand now that you're building on top of the class MyRepository
include Elasticsearch::Persistence::Repository
include Elasticsearch::Persistence::Repository::ConfigDSL
index_name :foo
…
end … the methods in
Great! Agreed :)
Yeah, that's fair – it's easy enough to do this in your own codebase, and means you can extend functionality in your particular repository as you please. Having a |
Hi @jits
Yes, this is definitely not ideal but in order to keep this refactor manageable and modular, I am ok with having the awkwardness for now. I can always go back and decouple the two gems later in a non-major version, as long as the API remains constant. For now, I do like your suggestion of having the methods be kept in their own DSL mixin. That way, I can isolate the less ideal link between the two gems in one place and refactor it later, if I need to.
I'm not opposed to adding one, but I'd rather start as simple as possible and add functionality and convenience if people ask for it. A base repository would be easy and no problem to add in a minor version. Thanks again! |
d45ec13
to
535733a
Compare
…included separately
535733a
to
a98e77b
Compare
* [STORE] Refactor Repository * [STORE] Add more tests and update documentation * [STORE] Remove #with method * [STORE] Raise NotImplementedError if administrative index methods are called on a Repository class * [STORE] Put class-level index admin methods into a DSL module, to be included separately * [STORE] Fix documentation and minor typos in tests * [STORE] Add one more test for ArgumentError on #search * [STORE] Remove test unit files and define only test 'integration' and 'all' rake tasks
@jits Just FYI, I've merged this and released 6.0.0.pre if you'd like to try it out. Thanks! |
@estolfo – awesome! Thanks for the heads up. I'm hoping to upgrade one of our apps to ES 6.x in the foreseeable future, so may get a chance to play with this then. |
@jits The gems will most likely work with ES 5 as well, but I'd recommend sticking with your test environment. |
This pull request offers an alternative refactor to this pull request of
Elasticsearch::Persistence::Repository
. It provides a mixin that users can include to get Repository behavior on classes.example: