Conversation
|
Very useful! |
|
Not sure yet, I'll first need to add support for those things that are still missing, or it won't add anything to the existing INI support. You can contribute to the discussion here: https://groups.google.com/forum/#!topic/meetecho-janus/yrSPbANpDVM |
|
Thank you, I will try it next week. Even if it does not add anything new it's still a feature. |
Yep.
At the moment the core is the only part that tries to load a .yaml file, so even just playing with janus.yaml and the different settings and making sure they're all still picked correctly would already help. Converting a plugin .cfg file to .yaml and have the plugin load that one instead would also be helpful, as we want to make that step too sooner or later. |
|
😎 |
Try to load .yaml by default, and fallback to .cfg if not found
|
IS IT DONE? |
|
AND NOW? |
|
With the nesting abilities of YAML wouldn't it make sense to inline the plugin configuration in the main configuration file? Of course this is a bigger change and not easily made backwards-compatible.
I suppose the other reason is that you want to keep this convention relaxed and not force plugins to serialize to/from passed-in YAML objects? |
No, as plugins can load whatever kind of configuration they want: the fact the stock plugins follow the same format as the core is just a convention in our repo, but nothing prevents you to write your own plugin that loads an XML config, for instance. All plugins get at startup is the path where configurations can be found, and they're free to ignore that too. |
|
This last commit adds support for subcategories (no arrays yet). Core and plugins don't use them yet, but this still required some breaking change in how the I tried to make the changes in the API as simple as possible, so I'll summarize them here for plugin developers that currently make use of this: janus_config_get_categoriesNotice the extra janus_config_get_categoryNotice how to get a root category, or: to traverse the document until you get to the "sport" category that is deep within those parent categories instead. janus_config_add_categoryAs you can see, we just added a janus_config_remove_categorySame exact considerations as for janus_config_add_itemHere we only changed the type of Notice that if this means a subcategory, you must first look for the right category and then pass it to this method: previously the method would do that for you. Doing the same would have required a variable list of arguments in here as well, which seemed overkill and very inefficient. janus_config_remove_itemSame exact considerations as for janus_config_get_itemNo change. janus_config_get_item_drilldownThis method has gone, it's not part of the API anymore. See the considerations I made for instead of: which should be more efficient as you don't look for the category each time you try to get an item, which is what Adapting your plugin to the new APIIf you want to adapt your current plugin without using indented stuff yet, it should be very easy:
Again, looking at the diff for core and plugins should clarify how easy the transition is. Feedback welcome! |
|
Finally added support for sequences/arrays, even though just for strings and not for mappings/objects yet. Anyway, this forced me to considerable refactor the config API, meaning the summary I made a few days ago is now obsolete... That said, I believe the refactoring I did now is much more flexible, and more importantly clean from a programming perspective. The old config API did a lot of assumptions, and masqued several things behind the curtains. This made it quite constrained, and proved unusable for these new concepts. The new API is much cleaner, and is inspired from the Jansson API. For instance, to add something to a config:
Lookup is cleaner as well, and so is the removal of nodes from the object. It's quite late here, so I don't have time to summarize the API changes right now, but again, even though this is a refactoring, updating your code to use the new API will be much less work than you fear. I'll make some examples tomorrow, by referring to how some of the plugins use it now. Now that we have sequences, the plan is to also start using these new concepts in the Janus core configuration somehow. One example might be the ability to configure more than one STUN server, which is something someone showed interest for a few weeks ago. This should give us a practical usage for all this new stuff, which will anyway be very useful for the things we're planning next. |
|
Just FYI, I ditched YAML for the libconfig format, which I like more in general and the library is much less of a pain. I'll publish a PR shortly. Closing this. |

See discussion in this post on the Google group.
This patch adds support for YAML configuration files. Whether the INI or YAML parser is used only depends on the extension of the file you feed it: if it's
.yaml, YAML is used, otherwise we parse the file exactly as before. In both cases, you end up with ajanus_configfile, so the very same methods (involving categories and items) work no matter the format, which means it's completely backwards compatible. Saving a file to YAML or INI, instead, depends on theis_yamlproperty onjanus_config, e.g.:The patch also lays the ground for future enhancements, namely subcategories and sequences/array. At the moment subcategories are defined but not parsed/used (no plugin currently uses them anyway). For sequences/arrays I'll have to think about how to represent them internally (it will probably be some new API in
config.hto represent the new object). In order to facilitate all this, I got rid of the originaljanus_config_category, which is now an alias forjanus_config_itemfor backwards compatibility.As a proof of concept, I've converted the
janus.cfgfile to ajanus.yamlfile, and it seems to be working as expected. Feedback welcome!