Trendyol / go-dcp-kafka

The Go implementation of the Couchbase to Kafka with DCP.
MIT License
67 stars 15 forks source link

Add mapstructure tags to config structures for viper config read package support #69

Closed emrekosen closed 9 months ago

emrekosen commented 11 months ago

Is your feature request related to a problem? Please describe. When using viper package to read config files, we can't parse config directly to struct provided by package which is config.Connector . It's because viper uses mapstructure tags and we have yaml tags. With yaml:",inline" tag dcp field in config.Connector, viper unable to read inlined config fields.

Describe the solution you'd like If we add mapstructure tags to config struct it will be resolved.

emrekosen commented 11 months ago

I can do this since it's 1 minute solution :) Also we need this in go-dcp and other projects.

Abdulsametileri commented 11 months ago

Thank you, I want to ask a question. If we did this, what would be their benefits?

emrekosen commented 11 months ago

Right now we can't read configs with viper package by just parsing viper data to config.Connector struct. If anybody wants to use viper it's not possible. In our team we use viper for dynamic configuration also and it will provide that.

Our current logic is parsing config file to another struct and map it to config.Connector.

I don't know if i explained well. I can provide more detail.

mhmtszr commented 11 months ago

@emrekosen I understand your concerns you are right. If we remove the inline tag and add mapstructure, will it work the same? We need to test it. If you find an available time I would be happy to review your pull request.

emrekosen commented 11 months ago

@mhmtszr No we don't need to remove inline tag, we can use both yaml and mapstructure. With a tag like yaml:",inline" mapstructure:",squash" we can support both inline yaml and inline mapstrucure. I will implement and create pull request.