Class: Rdkafka::Admin
- Inherits:
-
Object
- Object
- Rdkafka::Admin
- Includes:
- Helpers::OAuth
- Defined in:
- lib/rdkafka/admin.rb,
lib/rdkafka/admin/create_acl_handle.rb,
lib/rdkafka/admin/create_acl_report.rb,
lib/rdkafka/admin/delete_acl_handle.rb,
lib/rdkafka/admin/delete_acl_report.rb,
lib/rdkafka/admin/acl_binding_result.rb,
lib/rdkafka/admin/create_topic_handle.rb,
lib/rdkafka/admin/create_topic_report.rb,
lib/rdkafka/admin/delete_topic_handle.rb,
lib/rdkafka/admin/delete_topic_report.rb,
lib/rdkafka/admin/describe_acl_handle.rb,
lib/rdkafka/admin/describe_acl_report.rb,
lib/rdkafka/admin/delete_groups_handle.rb,
lib/rdkafka/admin/delete_groups_report.rb,
lib/rdkafka/admin/config_binding_result.rb,
lib/rdkafka/admin/describe_configs_handle.rb,
lib/rdkafka/admin/describe_configs_report.rb,
lib/rdkafka/admin/create_partitions_handle.rb,
lib/rdkafka/admin/create_partitions_report.rb,
lib/rdkafka/admin/config_resource_binding_result.rb,
lib/rdkafka/admin/incremental_alter_configs_handle.rb,
lib/rdkafka/admin/incremental_alter_configs_report.rb
Defined Under Namespace
Classes: AclBindingResult, ConfigBindingResult, ConfigResourceBindingResult, CreateAclHandle, CreateAclReport, CreatePartitionsHandle, CreatePartitionsReport, CreateTopicHandle, CreateTopicReport, DeleteAclHandle, DeleteAclReport, DeleteGroupsHandle, DeleteGroupsReport, DeleteTopicHandle, DeleteTopicReport, DescribeAclHandle, DescribeAclReport, DescribeConfigsHandle, DescribeConfigsReport, IncrementalAlterConfigsHandle, IncrementalAlterConfigsReport
Instance Method Summary collapse
-
#close ⇒ Object
Close this admin instance.
-
#closed? ⇒ Boolean
Whether this admin has closed.
-
#create_acl(resource_type:, resource_name:, resource_pattern_type:, principal:, host:, operation:, permission_type:) ⇒ CreateAclHandle
Create acl.
-
#create_partitions(topic_name, partition_count) ⇒ CreateTopicHandle
Creates extra partitions for a given topic.
-
#create_topic(topic_name, partition_count, replication_factor, topic_config = {}) ⇒ CreateTopicHandle
Create a topic with the given partition count and replication factor.
-
#delete_acl(resource_type:, resource_name:, resource_pattern_type:, principal:, host:, operation:, permission_type:) ⇒ DeleteAclHandle
Delete acl.
- #delete_group(group_id) ⇒ Object
-
#delete_topic(topic_name) ⇒ DeleteTopicHandle
Deletes the named topic.
-
#describe_acl(resource_type:, resource_name:, resource_pattern_type:, principal:, host:, operation:, permission_type:) ⇒ DescribeAclHandle
Describe acls.
-
#describe_configs(resources) ⇒ DescribeConfigsHandle
Describe configs.
- #finalizer ⇒ Object
-
#incremental_alter_configs(resources_with_configs) ⇒ IncrementalAlterConfigsHandle
Alters in an incremental way all the configs provided for given resources.
-
#metadata(topic_name = nil, timeout_ms = 2_000) ⇒ Metadata
Performs the metadata request using admin.
-
#name ⇒ String
Admin name.
-
#start ⇒ Object
Starts the native Kafka polling thread and kicks off the init polling.
Methods included from Helpers::OAuth
#oauthbearer_set_token, #oauthbearer_set_token_failure
Instance Method Details
#close ⇒ Object
Close this admin instance
46 47 48 49 50 |
# File 'lib/rdkafka/admin.rb', line 46 def close return if closed? ObjectSpace.undefine_finalizer(self) @native_kafka.close end |
#closed? ⇒ Boolean
Whether this admin has closed
53 54 55 |
# File 'lib/rdkafka/admin.rb', line 53 def closed? @native_kafka.closed? end |
#create_acl(resource_type:, resource_name:, resource_pattern_type:, principal:, host:, operation:, permission_type:) ⇒ CreateAclHandle
Create acl
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
# File 'lib/rdkafka/admin.rb', line 348 def create_acl(resource_type:, resource_name:, resource_pattern_type:, principal:, host:, operation:, permission_type:) closed_admin_check(__method__) # Create a rd_kafka_AclBinding_t representing the new acl error_buffer = FFI::MemoryPointer.from_string(" " * 256) new_acl_ptr = Rdkafka::Bindings.rd_kafka_AclBinding_new( resource_type, FFI::MemoryPointer.from_string(resource_name), resource_pattern_type, FFI::MemoryPointer.from_string(principal), FFI::MemoryPointer.from_string(host), operation, , error_buffer, 256 ) if new_acl_ptr.null? raise Rdkafka::Config::ConfigError.new(error_buffer.read_string) end # Note that rd_kafka_CreateAcls can create more than one acl at a time pointer_array = [new_acl_ptr] acls_array_ptr = FFI::MemoryPointer.new(:pointer) acls_array_ptr.write_array_of_pointer(pointer_array) # Get a pointer to the queue that our request will be enqueued on queue_ptr = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_queue_get_background(inner) end if queue_ptr.null? Rdkafka::Bindings.rd_kafka_AclBinding_destroy(new_acl_ptr) raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL") end # Create and register the handle that we will return to the caller create_acl_handle = CreateAclHandle.new create_acl_handle[:pending] = true create_acl_handle[:response] = -1 CreateAclHandle.register(create_acl_handle) = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_AdminOptions_new(inner, Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_CREATEACLS) end Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(, create_acl_handle.to_ptr) begin @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_CreateAcls( inner, acls_array_ptr, 1, , queue_ptr ) end rescue Exception CreateAclHandle.remove(create_acl_handle.to_ptr.address) raise ensure Rdkafka::Bindings.rd_kafka_AdminOptions_destroy() Rdkafka::Bindings.rd_kafka_queue_destroy(queue_ptr) Rdkafka::Bindings.rd_kafka_AclBinding_destroy(new_acl_ptr) end create_acl_handle end |
#create_partitions(topic_name, partition_count) ⇒ CreateTopicHandle
Creates extra partitions for a given topic
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/rdkafka/admin.rb', line 257 def create_partitions(topic_name, partition_count) closed_admin_check(__method__) @native_kafka.with_inner do |inner| error_buffer = FFI::MemoryPointer.from_string(" " * 256) new_partitions_ptr = Rdkafka::Bindings.rd_kafka_NewPartitions_new( FFI::MemoryPointer.from_string(topic_name), partition_count, error_buffer, 256 ) if new_partitions_ptr.null? raise Rdkafka::Config::ConfigError.new(error_buffer.read_string) end pointer_array = [new_partitions_ptr] topics_array_ptr = FFI::MemoryPointer.new(:pointer) topics_array_ptr.write_array_of_pointer(pointer_array) # Get a pointer to the queue that our request will be enqueued on queue_ptr = Rdkafka::Bindings.rd_kafka_queue_get_background(inner) if queue_ptr.null? Rdkafka::Bindings.rd_kafka_NewPartitions_destroy(new_partitions_ptr) raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL") end # Create and register the handle we will return to the caller create_partitions_handle = CreatePartitionsHandle.new create_partitions_handle[:pending] = true create_partitions_handle[:response] = -1 CreatePartitionsHandle.register(create_partitions_handle) = Rdkafka::Bindings.rd_kafka_AdminOptions_new(inner, Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_CREATEPARTITIONS) Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(, create_partitions_handle.to_ptr) begin Rdkafka::Bindings.rd_kafka_CreatePartitions( inner, topics_array_ptr, 1, , queue_ptr ) rescue Exception CreatePartitionsHandle.remove(create_partitions_handle.to_ptr.address) raise ensure Rdkafka::Bindings.rd_kafka_AdminOptions_destroy() Rdkafka::Bindings.rd_kafka_queue_destroy(queue_ptr) Rdkafka::Bindings.rd_kafka_NewPartitions_destroy(new_partitions_ptr) end create_partitions_handle end end |
#create_topic(topic_name, partition_count, replication_factor, topic_config = {}) ⇒ CreateTopicHandle
Create a topic with the given partition count and replication factor
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/rdkafka/admin.rb', line 65 def create_topic(topic_name, partition_count, replication_factor, topic_config={}) closed_admin_check(__method__) # Create a rd_kafka_NewTopic_t representing the new topic error_buffer = FFI::MemoryPointer.from_string(" " * 256) new_topic_ptr = Rdkafka::Bindings.rd_kafka_NewTopic_new( FFI::MemoryPointer.from_string(topic_name), partition_count, replication_factor, error_buffer, 256 ) if new_topic_ptr.null? raise Rdkafka::Config::ConfigError.new(error_buffer.read_string) end unless topic_config.nil? topic_config.each do |key, value| Rdkafka::Bindings.rd_kafka_NewTopic_set_config( new_topic_ptr, key.to_s, value.to_s ) end end # Note that rd_kafka_CreateTopics can create more than one topic at a time pointer_array = [new_topic_ptr] topics_array_ptr = FFI::MemoryPointer.new(:pointer) topics_array_ptr.write_array_of_pointer(pointer_array) # Get a pointer to the queue that our request will be enqueued on queue_ptr = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_queue_get_background(inner) end if queue_ptr.null? Rdkafka::Bindings.rd_kafka_NewTopic_destroy(new_topic_ptr) raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL") end # Create and register the handle we will return to the caller create_topic_handle = CreateTopicHandle.new create_topic_handle[:pending] = true create_topic_handle[:response] = -1 CreateTopicHandle.register(create_topic_handle) = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_AdminOptions_new(inner, Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_CREATETOPICS) end Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(, create_topic_handle.to_ptr) begin @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_CreateTopics( inner, topics_array_ptr, 1, , queue_ptr ) end rescue Exception CreateTopicHandle.remove(create_topic_handle.to_ptr.address) raise ensure Rdkafka::Bindings.rd_kafka_AdminOptions_destroy() Rdkafka::Bindings.rd_kafka_queue_destroy(queue_ptr) Rdkafka::Bindings.rd_kafka_NewTopic_destroy(new_topic_ptr) end create_topic_handle end |
#delete_acl(resource_type:, resource_name:, resource_pattern_type:, principal:, host:, operation:, permission_type:) ⇒ DeleteAclHandle
Delete acl
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/rdkafka/admin.rb', line 453 def delete_acl(resource_type:, resource_name:, resource_pattern_type:, principal:, host:, operation:, permission_type:) closed_admin_check(__method__) # Create a rd_kafka_AclBinding_t representing the acl to be deleted error_buffer = FFI::MemoryPointer.from_string(" " * 256) delete_acl_ptr = Rdkafka::Bindings.rd_kafka_AclBindingFilter_new( resource_type, resource_name ? FFI::MemoryPointer.from_string(resource_name) : nil, resource_pattern_type, principal ? FFI::MemoryPointer.from_string(principal) : nil, host ? FFI::MemoryPointer.from_string(host) : nil, operation, , error_buffer, 256 ) if delete_acl_ptr.null? raise Rdkafka::Config::ConfigError.new(error_buffer.read_string) end # Note that rd_kafka_DeleteAcls can delete more than one acl at a time pointer_array = [delete_acl_ptr] acls_array_ptr = FFI::MemoryPointer.new(:pointer) acls_array_ptr.write_array_of_pointer(pointer_array) # Get a pointer to the queue that our request will be enqueued on queue_ptr = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_queue_get_background(inner) end if queue_ptr.null? Rdkafka::Bindings.rd_kafka_AclBinding_destroy(new_acl_ptr) raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL") end # Create and register the handle that we will return to the caller delete_acl_handle = DeleteAclHandle.new delete_acl_handle[:pending] = true delete_acl_handle[:response] = -1 DeleteAclHandle.register(delete_acl_handle) = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_AdminOptions_new(inner, Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_DELETEACLS) end Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(, delete_acl_handle.to_ptr) begin @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_DeleteAcls( inner, acls_array_ptr, 1, , queue_ptr ) end rescue Exception DeleteAclHandle.remove(delete_acl_handle.to_ptr.address) raise ensure Rdkafka::Bindings.rd_kafka_AdminOptions_destroy() Rdkafka::Bindings.rd_kafka_queue_destroy(queue_ptr) Rdkafka::Bindings.rd_kafka_AclBinding_destroy(delete_acl_ptr) end delete_acl_handle end |
#delete_group(group_id) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/rdkafka/admin.rb', line 137 def delete_group(group_id) closed_admin_check(__method__) # Create a rd_kafka_DeleteGroup_t representing the new topic delete_groups_ptr = Rdkafka::Bindings.rd_kafka_DeleteGroup_new( FFI::MemoryPointer.from_string(group_id) ) pointer_array = [delete_groups_ptr] groups_array_ptr = FFI::MemoryPointer.new(:pointer) groups_array_ptr.write_array_of_pointer(pointer_array) # Get a pointer to the queue that our request will be enqueued on queue_ptr = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_queue_get_background(inner) end if queue_ptr.null? Rdkafka::Bindings.rd_kafka_DeleteTopic_destroy(delete_topic_ptr) raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL") end # Create and register the handle we will return to the caller delete_groups_handle = DeleteGroupsHandle.new delete_groups_handle[:pending] = true delete_groups_handle[:response] = -1 DeleteGroupsHandle.register(delete_groups_handle) = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_AdminOptions_new(inner, Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_DELETETOPICS) end Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(, delete_groups_handle.to_ptr) begin @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_DeleteGroups( inner, groups_array_ptr, 1, , queue_ptr ) end rescue Exception DeleteGroupsHandle.remove(delete_groups_handle.to_ptr.address) raise ensure Rdkafka::Bindings.rd_kafka_AdminOptions_destroy() Rdkafka::Bindings.rd_kafka_queue_destroy(queue_ptr) Rdkafka::Bindings.rd_kafka_DeleteGroup_destroy(delete_groups_ptr) end delete_groups_handle end |
#delete_topic(topic_name) ⇒ DeleteTopicHandle
Deletes the named topic
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/rdkafka/admin.rb', line 195 def delete_topic(topic_name) closed_admin_check(__method__) # Create a rd_kafka_DeleteTopic_t representing the topic to be deleted delete_topic_ptr = Rdkafka::Bindings.rd_kafka_DeleteTopic_new(FFI::MemoryPointer.from_string(topic_name)) # Note that rd_kafka_DeleteTopics can create more than one topic at a time pointer_array = [delete_topic_ptr] topics_array_ptr = FFI::MemoryPointer.new(:pointer) topics_array_ptr.write_array_of_pointer(pointer_array) # Get a pointer to the queue that our request will be enqueued on queue_ptr = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_queue_get_background(inner) end if queue_ptr.null? Rdkafka::Bindings.rd_kafka_DeleteTopic_destroy(delete_topic_ptr) raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL") end # Create and register the handle we will return to the caller delete_topic_handle = DeleteTopicHandle.new delete_topic_handle[:pending] = true delete_topic_handle[:response] = -1 DeleteTopicHandle.register(delete_topic_handle) = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_AdminOptions_new(inner, Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_DELETETOPICS) end Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(, delete_topic_handle.to_ptr) begin @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_DeleteTopics( inner, topics_array_ptr, 1, , queue_ptr ) end rescue Exception DeleteTopicHandle.remove(delete_topic_handle.to_ptr.address) raise ensure Rdkafka::Bindings.rd_kafka_AdminOptions_destroy() Rdkafka::Bindings.rd_kafka_queue_destroy(queue_ptr) Rdkafka::Bindings.rd_kafka_DeleteTopic_destroy(delete_topic_ptr) end delete_topic_handle end |
#describe_acl(resource_type:, resource_name:, resource_pattern_type:, principal:, host:, operation:, permission_type:) ⇒ DescribeAclHandle
Describe acls
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 |
# File 'lib/rdkafka/admin.rb', line 560 def describe_acl(resource_type:, resource_name:, resource_pattern_type:, principal:, host:, operation:, permission_type:) closed_admin_check(__method__) # Create a rd_kafka_AclBinding_t with the filters to fetch existing acls error_buffer = FFI::MemoryPointer.from_string(" " * 256) describe_acl_ptr = Rdkafka::Bindings.rd_kafka_AclBindingFilter_new( resource_type, resource_name ? FFI::MemoryPointer.from_string(resource_name) : nil, resource_pattern_type, principal ? FFI::MemoryPointer.from_string(principal) : nil, host ? FFI::MemoryPointer.from_string(host) : nil, operation, , error_buffer, 256 ) if describe_acl_ptr.null? raise Rdkafka::Config::ConfigError.new(error_buffer.read_string) end # Get a pointer to the queue that our request will be enqueued on queue_ptr = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_queue_get_background(inner) end if queue_ptr.null? Rdkafka::Bindings.rd_kafka_AclBinding_destroy(new_acl_ptr) raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL") end # Create and register the handle that we will return to the caller describe_acl_handle = DescribeAclHandle.new describe_acl_handle[:pending] = true describe_acl_handle[:response] = -1 DescribeAclHandle.register(describe_acl_handle) = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_AdminOptions_new(inner, Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_DESCRIBEACLS) end Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(, describe_acl_handle.to_ptr) begin @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_DescribeAcls( inner, describe_acl_ptr, , queue_ptr ) end rescue Exception DescribeAclHandle.remove(describe_acl_handle.to_ptr.address) raise ensure Rdkafka::Bindings.rd_kafka_AdminOptions_destroy() Rdkafka::Bindings.rd_kafka_queue_destroy(queue_ptr) Rdkafka::Bindings.rd_kafka_AclBinding_destroy(describe_acl_ptr) end describe_acl_handle end |
#describe_configs(resources) ⇒ DescribeConfigsHandle
Several resources can be requested at one go, but only one broker at a time
Describe configs
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 |
# File 'lib/rdkafka/admin.rb', line 634 def describe_configs(resources) closed_admin_check(__method__) handle = DescribeConfigsHandle.new handle[:pending] = true handle[:response] = -1 queue_ptr = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_queue_get_background(inner) end if queue_ptr.null? raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL") end = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_AdminOptions_new( inner, Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_DESCRIBECONFIGS ) end DescribeConfigsHandle.register(handle) Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(, handle.to_ptr) pointer_array = resources.map do |resource_details| Rdkafka::Bindings.rd_kafka_ConfigResource_new( resource_details.fetch(:resource_type), FFI::MemoryPointer.from_string( resource_details.fetch(:resource_name) ) ) end configs_array_ptr = FFI::MemoryPointer.new(:pointer, pointer_array.size) configs_array_ptr.write_array_of_pointer(pointer_array) begin @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_DescribeConfigs( inner, configs_array_ptr, pointer_array.size, , queue_ptr ) end rescue Exception DescribeConfigsHandle.remove(handle.to_ptr.address) raise ensure Rdkafka::Bindings.rd_kafka_ConfigResource_destroy_array( configs_array_ptr, pointer_array.size ) if configs_array_ptr end handle end |
#finalizer ⇒ Object
28 29 30 |
# File 'lib/rdkafka/admin.rb', line 28 def finalizer ->(_) { close } end |
#incremental_alter_configs(resources_with_configs) ⇒ IncrementalAlterConfigsHandle
Several resources can be requested at one go, but only one broker at a time
The results won't contain altered values but only the altered resources
Alters in an incremental way all the configs provided for given resources
name, value and the proper op_type to perform on this value.
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'lib/rdkafka/admin.rb', line 707 def incremental_alter_configs(resources_with_configs) closed_admin_check(__method__) handle = IncrementalAlterConfigsHandle.new handle[:pending] = true handle[:response] = -1 queue_ptr = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_queue_get_background(inner) end if queue_ptr.null? raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL") end = @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_AdminOptions_new( inner, Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_INCREMENTALALTERCONFIGS ) end IncrementalAlterConfigsHandle.register(handle) Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(, handle.to_ptr) # Tu poprawnie tworzyc pointer_array = resources_with_configs.map do |resource_details| # First build the appropriate resource representation resource_ptr = Rdkafka::Bindings.rd_kafka_ConfigResource_new( resource_details.fetch(:resource_type), FFI::MemoryPointer.from_string( resource_details.fetch(:resource_name) ) ) resource_details.fetch(:configs).each do |config| Bindings.rd_kafka_ConfigResource_add_incremental_config( resource_ptr, config.fetch(:name), config.fetch(:op_type), config.fetch(:value) ) end resource_ptr end configs_array_ptr = FFI::MemoryPointer.new(:pointer, pointer_array.size) configs_array_ptr.write_array_of_pointer(pointer_array) begin @native_kafka.with_inner do |inner| Rdkafka::Bindings.rd_kafka_IncrementalAlterConfigs( inner, configs_array_ptr, pointer_array.size, , queue_ptr ) end rescue Exception IncrementalAlterConfigsHandle.remove(handle.to_ptr.address) raise ensure Rdkafka::Bindings.rd_kafka_ConfigResource_destroy_array( configs_array_ptr, pointer_array.size ) if configs_array_ptr end handle end |
#metadata(topic_name = nil, timeout_ms = 2_000) ⇒ Metadata
Performs the metadata request using admin
37 38 39 40 41 42 43 |
# File 'lib/rdkafka/admin.rb', line 37 def (topic_name = nil, timeout_ms = 2_000) closed_admin_check(__method__) @native_kafka.with_inner do |inner| Metadata.new(inner, topic_name, timeout_ms) end end |
#name ⇒ String
Returns admin name.
22 23 24 25 26 |
# File 'lib/rdkafka/admin.rb', line 22 def name @name ||= @native_kafka.with_inner do |inner| ::Rdkafka::Bindings.rd_kafka_name(inner) end end |
#start ⇒ Object
Not needed to run unless explicit start was disabled
Starts the native Kafka polling thread and kicks off the init polling
17 18 19 |
# File 'lib/rdkafka/admin.rb', line 17 def start @native_kafka.start end |