Open drgomesp opened 8 years ago
Imho Loader itself should not depend on file extension and should take some kind of map or generally a structure as a parameter. Then we can just add adapters for YAML, JSON, XML or whatever else. What do you think?
Good idea @krzysztof-gzocha. We could have something like:
type Configuration struct {
Definitions []definition.Definition;
}
And the adapters would simply return an instance of Configuration
. Is that what you were thinking?
Exactly, but I'm not sure if path is really required inside config. I understand config as a service which knows all the definitions. I found it would be something abstract like Loader::load(path string)
and it's implementation like JsonLoader::load()
or YamlLoader::load()
.
Loader will return Configration
for sure, but do we need path to be inside this returned object? I don't think so
@krzysztof-gzocha you're right. The Configuration
should be unaware of how it gets created.
One should be able to register service definitions through a configuration file, as the example below: