add toggle to split nats kv on "." delimiter#355
Conversation
|
@TECHNOFAB11 Perhaps you'll want to look at this, as the original contributor of the nats provider? |
|
Looks good, it's been a while since I've seen my NATS provider code and I actually expected it to unflatten the data, so it's definitely a good idea to add the option to do that :) |
|
An alternative, since you expected it to unflatten already, is to just make this the default behavior and jot even have a config option. Though, that would unfortunately break people's code if they're using it... |
Yeah probably best to not break existing code even though it would be the expected outcome. PR is fine as is :) |
|
Hey @knadh, I made the requested change. Does this seem ready to merge? |
|
@nickchomey sorry, I lost track of this. Tagged |
This adds an optional "split" boolean config field to allow for splitting/unflattening a natskv key on the "." delimiter that denotes NATS KV subject/key hierarchies
My use case is:
Prefix = "abc"
There's a key "abc.xyz" with a value of "123"
Currently it will filter for keys with the "abc" prefix (minimizing kv.Get() calls), but then it just ends up setting
{ "abc.xyz" : 123 }in the koanf confmap.This PR allows it to split the key so that the conf map gets updated with something like this (or whatever the proper nested map syntax is in go)
Inspiration taken from the env provider (and surely many others do something similar)
I'm quite open to renaming the field to something other than Split, as well as changing its comment description