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

ServerOptions and ClientOptions use untyped dynamic options #319

Merged
merged 4 commits into from
Jun 11, 2021

Conversation

marioizquierdo
Copy link
Contributor

Fixes issue #316

Allow backwards compatibility when a new option is added

Every time a new server or client option is added, that would add a new property in the ServerOptions or ClientOptions struct, that is used from the generated code, forcing an upgrade on the runtime library even if the new option is not being used.

Now, the generated code will read options with the generic method ReadOpt, for example:

var pathPrefix string
ok := opts.ReadOpt("pathPrefix", &pathPrefix)

Example with a new option

If in the future a new option is added, let's say "foobar", the newly generated code will still work with older versions of the runtime:

// new generated code:
var foobar int
ok := opts.ReadOpt("foobar", &foobar)

This generated code will work with older versions of the runtime, that still don't know about the option. The method ReadOpt will just return false, which the same if the option was not set by the user.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@marioizquierdo marioizquierdo merged commit ef48131 into main Jun 11, 2021
@marioizquierdo marioizquierdo deleted the options_typeless_getters branch June 11, 2021 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant