Class: Kafka::FFI::Admin::ConfigResource

Inherits:
OpaquePointer show all
Defined in:
lib/kafka/ffi/admin/config_resource.rb

Instance Attribute Summary

Attributes inherited from OpaquePointer

#pointer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OpaquePointer

by_ref, from_native, inherited, #initialize, to_native

Constructor Details

This class inherits a constructor from Kafka::FFI::OpaquePointer

Class Method Details

.new(type, name) ⇒ Object

Create a new ConfigResource

Examples:

Build ConfigResource for a topic

ConfigResource.new(:topic, "events")

Build ConfigResource for a broker

ConfigResource.new(:broker, broker_id)

Parameters:

  • type (:broker, :topic, :group)

    Type of config resource

  • name (String)

    Name of resource (broker_id, topic name, etc…)

See Also:

  • resource_type enum


19
20
21
# File 'lib/kafka/ffi/admin/config_resource.rb', line 19

def self.new(type, name)
  ::Kafka::FFI.rd_kafka_ConfigResource_new(type, name)
end

Instance Method Details

#configsArray<ConfigEntry>

Retrieve an array of ConfigEntry from the resource.

Returns:

  • (Array<ConfigEntry>)

    Config entries for the resource



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/kafka/ffi/admin/config_resource.rb', line 44

def configs
  count = ::FFI::MemoryPointer.new(:pointer)

  configs = ::Kafka::FFI.rd_kafka_ConfigResource_configs(self, count)
  if configs.null?
    return nil
  end

  configs = configs.read_array_of_pointer(count.read(:size_t))
  configs.map! { |p| ConfigEntry.from_native(p, nil) }
ensure
  count.free
end

#destroyObject

Destroy the ConfigResource, returning its resources back to the system.



97
98
99
# File 'lib/kafka/ffi/admin/config_resource.rb', line 97

def destroy
  ::Kafka::FFI.rd_kafka_ConfigResource_destroy(self)
end

#errornil, Kafka::ResponseError

Note:

Only set when ConfigResource was returned from AlterConfigs.

Returns the response error received from an AlterConfigs request.

Returns:



80
81
82
83
# File 'lib/kafka/ffi/admin/config_resource.rb', line 80

def error
  err = ::Kafka::FFI.rd_kafka_ConfigResource_error(self)
  err == :ok ? nil : ::Kafka::ResponseError.new(err)
end

#error_stringnil, String

Note:

Only set when ConfigResource was returned from AlterConfigs.

Returns a string describing the error received for this resource during an AlterConfigs request.

Returns:

  • (nil)

    No error

  • (String)

    AlterConfig request error



92
93
94
# File 'lib/kafka/ffi/admin/config_resource.rb', line 92

def error_string
  ::Kafka::FFI.rd_kafka_ConfigResource_error_string(self)
end

#nameString

Returns the config option name

Returns:

  • (String)

    Name of the config



70
71
72
# File 'lib/kafka/ffi/admin/config_resource.rb', line 70

def name
  ::Kafka::FFI.rd_kafka_ConfigResource_name(self)
end

#set_config(name, value) ⇒ Object

Note:

This will overwrite the current value

Set configuration name and value pair

Parameters:

  • name (String)

    Config option name

  • value (nil)

    Revert config to default

  • value (String)

    Value to set config option to

Raises:



32
33
34
35
36
37
38
39
# File 'lib/kafka/ffi/admin/config_resource.rb', line 32

def set_config(name, value)
  err = ::Kafka::FFI.rd_kafka_ConfigResource_set_config(self, name, value)
  if err != :ok
    raise ::Kafka::ResponseError, err
  end

  nil
end

#typeSymbol

Returns the type of the resource

Returns:

  • (Symbol)

    Type of config resource

See Also:

  • resource_type enum


63
64
65
# File 'lib/kafka/ffi/admin/config_resource.rb', line 63

def type
  ::Kafka::FFI.rd_kafka_ConfigResource_type(self)
end