Class: Karafka::Admin::Configs::Config
- Inherits:
-
Object
- Object
- Karafka::Admin::Configs::Config
- Defined in:
- lib/karafka/admin/configs/config.rb
Overview
Represents a single config entry that is related to a resource
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#synonyms ⇒ Object
readonly
Returns the value of attribute synonyms.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.from_rd_kafka(rd_kafka_config) ⇒ Config
Creates a single config entry from the Rdkafka config result entry.
Instance Method Summary collapse
-
#default? ⇒ Boolean
Is the config property is set to its default value on the broker.
-
#initialize(name:, value:, default: -1,, read_only: -1,, sensitive: -1,, synonym: -1,, synonyms: []) ⇒ Config
constructor
Creates new config instance either for reading or as part of altering operation.
-
#read_only? ⇒ Boolean
Is the config property is read-only on the broker.
-
#sensitive? ⇒ Boolean
If the config property contains sensitive information (such as security configuration.
-
#synonym? ⇒ Boolean
Is this entry is a synonym.
-
#to_native_hash ⇒ Hash
Hash that we can use to operate with rdkafka.
Constructor Details
#initialize(name:, value:, default: -1,, read_only: -1,, sensitive: -1,, synonym: -1,, synonyms: []) ⇒ Config
For alter operations only ‘name` and `value` are needed
Creates new config instance either for reading or as part of altering operation
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/karafka/admin/configs/config.rb', line 41 def initialize( name:, value:, default: -1, read_only: -1, sensitive: -1, synonym: -1, synonyms: [] ) @name = name @value = value @synonyms = [] @default = default @read_only = read_only @sensitive = sensitive @synonym = synonym @synonyms = synonyms end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/karafka/admin/configs/config.rb', line 8 def name @name end |
#synonyms ⇒ Object (readonly)
Returns the value of attribute synonyms.
8 9 10 |
# File 'lib/karafka/admin/configs/config.rb', line 8 def synonyms @synonyms end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
8 9 10 |
# File 'lib/karafka/admin/configs/config.rb', line 8 def value @value end |
Class Method Details
.from_rd_kafka(rd_kafka_config) ⇒ Config
Creates a single config entry from the Rdkafka config result entry
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/karafka/admin/configs/config.rb', line 15 def from_rd_kafka(rd_kafka_config) new( name: rd_kafka_config.name, value: rd_kafka_config.value, read_only: rd_kafka_config.read_only, default: rd_kafka_config.default, sensitive: rd_kafka_config.sensitive, synonym: rd_kafka_config.synonym, synonyms: rd_kafka_config.synonyms.map do |rd_kafka_synonym| from_rd_kafka(rd_kafka_synonym) end ) end |
Instance Method Details
#default? ⇒ Boolean
Returns Is the config property is set to its default value on the broker.
61 |
# File 'lib/karafka/admin/configs/config.rb', line 61 def default? = @default.positive? |
#read_only? ⇒ Boolean
Returns Is the config property is read-only on the broker.
64 |
# File 'lib/karafka/admin/configs/config.rb', line 64 def read_only? = @read_only.positive? |
#sensitive? ⇒ Boolean
Returns if the config property contains sensitive information (such as security configuration.
68 |
# File 'lib/karafka/admin/configs/config.rb', line 68 def sensitive? = @sensitive.positive? |
#synonym? ⇒ Boolean
Returns is this entry is a synonym.
71 |
# File 'lib/karafka/admin/configs/config.rb', line 71 def synonym? = @synonym.positive? |
#to_native_hash ⇒ Hash
Returns hash that we can use to operate with rdkafka.
74 75 76 77 |
# File 'lib/karafka/admin/configs/config.rb', line 74 def to_native_hash = { name: name, value: value }.freeze |