Class: Kafka::FFI::Admin::AdminOptions

Inherits:
OpaquePointer show all
Defined in:
lib/kafka/ffi/admin/admin_options.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(client, api) ⇒ Object



7
8
9
# File 'lib/kafka/ffi/admin/admin_options.rb', line 7

def self.new(client, api)
  ::Kafka::FFI.rd_kafka_AdminOptions_new(client, api)
end

Instance Method Details

#destroyObject



117
118
119
# File 'lib/kafka/ffi/admin/admin_options.rb', line 117

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

#set_broker(broker_id) ⇒ Object Also known as: broker=

Note:

This API shoudl typically not be used and primarily serves as a workaround in some cases.

Override which broker the Admin request will be sent to. By default, requests are sent to the controller Broker with a couple exceptions (see librdkafka)

Parameters:

  • broker_id (Integer)

    ID of the Broker to receive the request.

See Also:

  • rd_kafka_AdminOptions_set_broker


96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/kafka/ffi/admin/admin_options.rb', line 96

def set_broker(broker_id)
  error = ::FFI::MemoryPointer.new(:char, 512)

  resp = ::Kafka::FFI.rd_kafka_AdminOptions_set_broker(self, broker_id, error, error.size)
  if resp != :ok
    raise ::Kafka::ResponseError.new(resp, error.read_string)
  end

  nil
ensure
  error.free
end

#set_operation_timeout(timeout) ⇒ Object Also known as: operation_timeout=

Set the broker’s operation wait timeout for the request to be processed by the cluster.

Only valid for :create_topics, :delete_topics, and :create_partitions operations.

Parameters:

  • timeout (-1, 0)

    Return immediately after starting the operation.

  • timeout (Integer)

    Max time to wait in milliseconds for the operation to propogate to the cluster.

Raises:



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/kafka/ffi/admin/admin_options.rb', line 51

def set_operation_timeout(timeout)
  error = ::FFI::MemoryPointer.new(:char, 512)

  resp = ::Kafka::FFI.rd_kafka_AdminOptions_set_operation_timeout(self, timeout, error, error.size)
  if resp != :ok
    raise ::Kafka::ResponseError.new(resp, error.read_string)
  end

  nil
ensure
  error.free
end

#set_request_timeout(timeout) ⇒ Object Also known as: request_timeout=

Note:

Default request timeout is ‘socket.timeout.ms` config option.

Sets the overall request timeout which includes broker lookup, request transmissing, operation time, and response processing.

Valid for all admin requests.

Parameters:

  • timeout (-1)

    Wait indefinitely for request to finish

  • timeout (Integer)

    Time to wait in milliseconds for request to be processed.

Raises:



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kafka/ffi/admin/admin_options.rb', line 26

def set_request_timeout(timeout)
  error = ::FFI::MemoryPointer.new(:char, 512)

  resp = ::Kafka::FFI.rd_kafka_AdminOptions_set_request_timeout(self, timeout, error, error.size)
  if resp != :ok
    raise ::Kafka::ResponseError.new(resp, error.read_string)
  end

  nil
ensure
  error.free
end

#set_validate_only(on) ⇒ Object Also known as: validate_only=

Tell the broker to only validate the request without actually performing the operation.

Only valid for :create_topics, :delete_topics, and :create_partitions operations.

Parameters:

  • on (Boolean)

    True to validate the request without performing it.

Raises:



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/kafka/ffi/admin/admin_options.rb', line 73

def set_validate_only(on)
  error = ::FFI::MemoryPointer.new(:char, 512)

  resp = ::Kafka::FFI.rd_kafka_AdminOptions_set_validate_only(self, on, error, error.size)
  if resp != :ok
    raise ::Kafka::ResponseError.new(resp, error.read_string)
  end

  nil
ensure
  error.free
end