Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opaque Config defaults #47

Closed
jehiah opened this issue Jun 14, 2014 · 5 comments
Closed

opaque Config defaults #47

jehiah opened this issue Jun 14, 2014 · 5 comments
Labels

Comments

@jehiah
Copy link
Member

jehiah commented Jun 14, 2014

It's not obvious from go-doc documentation what the default config values are, or what time some are, and there is no way to introspect them at runtime. Both seem like they should exist.

@mreiferson
Copy link
Member

Yea, I still can't say that this is the best we can do but I do appreciate the consistency. We lost type safety, but we didn't gain or lose anything when it comes to things being invalid only at runtime.

What we gained is one consistent way to set them (which is also capable or accepting serialized values from config files or over the wire).

The docs are a good suggestion.

@mreiferson
Copy link
Member

updated in bitly/master@43ff0ca

@jehiah
Copy link
Member Author

jehiah commented Jun 14, 2014

The type safety is one thing, but i'm having issues loosing static analysis being able to catch typos much much more. I'm really thinking about ways we can export variables from the config structure, and still leverage the Set() interface for loading from config files, and command line args but not loose the static analysis.

@mreiferson
Copy link
Member

I'm all ears 😄

@jehiah
Copy link
Member Author

jehiah commented Jun 15, 2014

How about leaving everything exported in the config object so you can initialize fields directly while continuing to leverage everything Set() gives us for loading in via command line flags, generic extensible reader-args, or from config file. We would then use the config object in a way that it's only useful to set values on the config object before passing it into a consumer/producer. The Consumer/Producer objects would make a deep copy of the config and store it in an unexpected variable, and any fields we expect to be mutated would have their own API to change them (directly by copying default values from config into an exported field or through a wrapper function to address where state has to be coordinated).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants