Refactor Source building
In #1058, we did one step from (dynamic factory + json) to a static enum world in order to have source type specific source params validation.
We are now half-way between two worlds.
Solution 1
Just go full enum. The factory is a function of the enum. Pros: Very simple Cons: Does not separate the concern super well.
Note: If we go for that route, source_type() should return an enum too.
Solution 2
Use a SourceParams trait that can build a Source type (does the job of the factory) and do dark magic, like what @fmassot did for the IndexConfig deserialization.
@fmassot @guilload what do you think?
yes totally! I must say that @guilload stopped himself in the middle of the river to have something ready for 0.2 :)
Solution 1 or solution 2?
I was working around that code yesterday, and I'm leaning towards solution 1. source_type() does now return an enum. We can dispatch directly and statically in load_source. We can optionally keep the SourceFactory trait around to preserve the decoupling.