From a3d9d6249831d62ae7d4501564aebf474f819e99 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Fri, 9 Oct 2020 02:15:00 -0600 Subject: [PATCH] generate: migrate config describing/altering to enums Besides ErrorCode, there may be one or two enums lurking out there. Known: - Op on incremental alter, but I don't think this is worth switching? - Mechanism on the new SCRAM apis. --- generate/definitions/32_describe_configs | 33 ++++----------- generate/definitions/33_alter_configs | 4 +- .../definitions/44_incremental_alter_configs | 6 +-- generate/definitions/enums | 41 +++++++++++++++++++ 4 files changed, 52 insertions(+), 32 deletions(-) diff --git a/generate/definitions/32_describe_configs b/generate/definitions/32_describe_configs index 33338eff..62d4d7aa 100644 --- a/generate/definitions/32_describe_configs +++ b/generate/definitions/32_describe_configs @@ -5,8 +5,7 @@ DescribeConfigsRequest => key 32, max version 3 // Resources is a list of resources to describe. Resources: [=>] // ResourceType is an enum corresponding to the type of config to describe. - // Valid values are 2 (topic), 4 (broker), or 8 (broker logger). - ResourceType: int8 + ResourceType: enum-ConfigResourceType // ResourceName is the name of config to describe. // // If the requested type is a topic, this corresponds to a topic name. @@ -53,7 +52,7 @@ DescribeConfigsResponse => // ErrorMessage is an informative message if the describe config failed. ErrorMessage: nullable-string // ResourceType is the enum corresponding to the type of described config. - ResourceType: int8 + ResourceType: enum-ConfigResourceType // ResourceName is the name corresponding to the describe config request. ResourceName: string // Configs contains information about key/value config pairs for @@ -69,24 +68,8 @@ DescribeConfigsResponse => // IsDefault is whether this is a default config option. This has been // replaced in favor of Source. IsDefault: bool // v0-v0 - // Source is where this config entry is from. Note that if there - // are no config synonyms, the source is DEFAULT_CONFIG. The values of - // this enum are as follows. - // - // UNKNOWN (0): unknown; e.g. an altar request was issued with no source set - // - // DYNAMIC_TOPIC_CONFIG (1): dynamic topic config for a specific topic - // - // DYNAMIC_BROKER_CONFIG (2): dynamic broker config for a specific broker - // - // DYNAMIC_DEFAULT_BROKER_CONFIG (3): dynamic broker config used as the default for all brokers in a cluster - // - // STATIC_BROKER_CONFIG (4): static broker config provided at start up - // - // DEFAULT_CONFIG (5): built-in default configuration for those that have defaults - // - // DYNAMIC_BROKER_LOGGER_CONFIG (6): broker logger; see KIP 412. - Source: int8(-1) // v1+ + // Source is where this config entry is from. + Source: enum-ConfigSource(-1) // v1+ // IsSensitive signifies whether this is a sensitive config key, which // is either a password or an unknown type. IsSensitive: bool @@ -95,10 +78,8 @@ DescribeConfigsResponse => ConfigSynonyms: [=>] // v1+ Name: string Value: nullable-string - Source: int8 - // ConfigType specifies the configuration data type. The values of this - // enum are as follows: UNKNOWN (0), BOOLEAN (1), STRING (2), INT (3), - // SHORT (4), LONG (5), DOUBLE (6), LIST (7), CLASS (8), PASSWORD (9). - ConfigType: int8 // v3+ + Source: enum-ConfigSource + // ConfigType specifies the configuration data type. + ConfigType: enum-ConfigType // v3+ // Documentation is optional documentation for the config entry. Documentation: nullable-string // v3+ diff --git a/generate/definitions/33_alter_configs b/generate/definitions/33_alter_configs index b6554baa..3154551c 100644 --- a/generate/definitions/33_alter_configs +++ b/generate/definitions/33_alter_configs @@ -16,7 +16,7 @@ AlterConfigsRequest => key 33, max version 1 Resources: [=>] // ResourceType is an enum corresponding to the type of config to alter. // The only two valid values are 2 (for topic) and 4 (for broker). - ResourceType: int8 + ResourceType: enum-ConfigResourceType // ResourceName is the name of config to alter. // // If the requested type is a topic, this corresponds to a topic name. @@ -67,6 +67,6 @@ AlterConfigsResponse => // ErrorMessage is an informative message if the alter config failed. ErrorMessage: nullable-string // ResourceType is the enum corresponding to the type of altered config. - ResourceType: int8 + ResourceType: enum-ConfigResourceType // ResourceName is the name corresponding to the alter config request. ResourceName: string diff --git a/generate/definitions/44_incremental_alter_configs b/generate/definitions/44_incremental_alter_configs index 50d38367..4d58a362 100644 --- a/generate/definitions/44_incremental_alter_configs +++ b/generate/definitions/44_incremental_alter_configs @@ -8,9 +8,7 @@ IncrementalAlterConfigsRequest => key 44, max version 1, flexible v1+ // Resources is an array of configs to alter. Resources: [=>] // ResourceType is an enum corresponding to the type of config to alter. - // The possible valid values are 2 (for topic), 4 (for broker), - // and 8 (for broker logger). - ResourceType: int8 + ResourceType: enum-ConfigResourceType // ResourceName is the name of config to alter. // // If the requested type is a topic, this corresponds to a topic name. @@ -74,7 +72,7 @@ IncrementalAlterConfigsResponse => // ErrorMessage is an informative message if the incremental alter config failed. ErrorMessage: nullable-string // ResourceType is the enum corresponding to the type of altered config. - ResourceType: int8 + ResourceType: enum-ConfigResourceType // ResourceName is the name corresponding to the incremental alter config // request. ResourceName: string diff --git a/generate/definitions/enums b/generate/definitions/enums index d87d069d..be1d7f57 100644 --- a/generate/definitions/enums +++ b/generate/definitions/enums @@ -1,3 +1,44 @@ +///////////// +// CONFIGS // +///////////// + +// A type of config. +ConfigResourceType int8 ( + 2: TOPIC + 4: BROKER + 8: BROKER_LOGGER +) + +// Where a config entry is from. If there are no config synonyms, +// the source is DEFAULT_CONFIG. +ConfigSource int8 ( + // Dynamic topic config for a specific topic. + 1: DYNAMIC_TOPIC_CONFIG + // Dynamic broker config for a specific broker. + 2: DYNAMIC_BROKER_CONFIG + // Dynamic broker config used as the default for all brokers in a cluster. + 3: DYNAMIC_DEFAULT_BROKER_CONFIG + // Static broker config provided at start up. + 4: STATIC_BROKER_CONFIG + // Build-in default configuration for those that have defaults. + 5: DEFAULT_CONFIG + // Broker logger; see KIP-412. + 6: DYNAMIC_BROKER_LOGGER_CONFIG +) + +// A configuration data type. +ConfigType int8 ( + 1: BOOLEAN + 2: STRING + 3: INT + 4: SHORT + 5: LONG + 6: DOUBLE + 7: LIST + 8: CLASS + 9: PASSWORD +) + ////////// // ACLS // //////////