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

Package config: Add types for common configuration needs. #83

Open
octo opened this issue May 19, 2020 · 0 comments
Open

Package config: Add types for common configuration needs. #83

octo opened this issue May 19, 2020 · 0 comments

Comments

@octo
Copy link
Member

octo commented May 19, 2020

The "config".Unmarshaler interface can be used to implement unmarshaling behavior that differs from the default. That can be used to support some recurring needs:

  • A type Port uint16 that accepts numeric and string values. If a string, "net".LookupPort is used to convert it to an integer. If the numeric value is outside of the 1–65535 range, an error is returned.
  • A type ServiceName string that is the inverse: a numeric value (in the 1–65535 range) is converted to a string.
  • Control mapping of multiple values onto a scalar type. For example, when mapping ["foo", "bar", "qux"] to a single string, should this result in an error (current behavior), the first value ("foo"), the last value ("qux"), or a random value? Special types could handle that. The "last value wins" / value is overwritten behavior is not uncommon in C plugins.
  • Provide minimum / maximum values for numeric values.
  • Check string values with a regular expression.
octo added a commit to octo/go-collectd that referenced this issue May 19, 2020
@octo octo linked a pull request May 20, 2020 that will close this issue
@octo octo removed a link to a pull request May 20, 2020
octo added a commit to octo/go-collectd that referenced this issue May 20, 2020
octo added a commit to octo/go-collectd that referenced this issue May 20, 2020
octo added a commit to octo/go-collectd that referenced this issue Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant