karafka-rdkafka 0.30.1-aarch64-linux-gnu → 0.31.0-aarch64-linux-gnu

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -27
  3. data/README.md +1 -0
  4. data/docker-compose-ssl.yml +1 -0
  5. data/docker-compose.yml +1 -0
  6. data/ext/librdkafka.so +0 -0
  7. data/karafka-rdkafka.gemspec +1 -1
  8. data/lib/rdkafka/admin/describe_cluster_handle.rb +31 -0
  9. data/lib/rdkafka/admin/describe_cluster_report.rb +48 -0
  10. data/lib/rdkafka/admin/describe_consumer_groups_handle.rb +31 -0
  11. data/lib/rdkafka/admin/describe_consumer_groups_report.rb +151 -0
  12. data/lib/rdkafka/admin/describe_result_parsing.rb +47 -0
  13. data/lib/rdkafka/admin/describe_topics_handle.rb +31 -0
  14. data/lib/rdkafka/admin/describe_topics_report.rb +118 -0
  15. data/lib/rdkafka/admin.rb +245 -0
  16. data/lib/rdkafka/bindings/admin/acls.rb +85 -0
  17. data/lib/rdkafka/bindings/admin/configs.rb +37 -0
  18. data/lib/rdkafka/bindings/admin/list_offsets.rb +26 -0
  19. data/lib/rdkafka/bindings/admin.rb +197 -0
  20. data/lib/rdkafka/bindings/callbacks.rb +148 -0
  21. data/lib/rdkafka/bindings/configuration.rb +50 -0
  22. data/lib/rdkafka/bindings/consumer.rb +83 -0
  23. data/lib/rdkafka/bindings/errors.rb +17 -0
  24. data/lib/rdkafka/bindings/handle.rb +16 -0
  25. data/lib/rdkafka/bindings/messages.rb +28 -0
  26. data/lib/rdkafka/bindings/metadata.rb +17 -0
  27. data/lib/rdkafka/bindings/polling.rb +17 -0
  28. data/lib/rdkafka/bindings/producer.rb +82 -0
  29. data/lib/rdkafka/bindings/share_consumer.rb +67 -0
  30. data/lib/rdkafka/bindings/structs.rb +62 -0
  31. data/lib/rdkafka/bindings.rb +13 -775
  32. data/lib/rdkafka/callbacks/describe_cluster_handler.rb +36 -0
  33. data/lib/rdkafka/callbacks/describe_consumer_groups_handler.rb +36 -0
  34. data/lib/rdkafka/callbacks/describe_topics_handler.rb +36 -0
  35. data/lib/rdkafka/callbacks.rb +10 -1
  36. data/lib/rdkafka/clients.rb +13 -46
  37. data/lib/rdkafka/consumer/message.rb +6 -9
  38. data/lib/rdkafka/defaults.rb +4 -0
  39. data/lib/rdkafka/producer/delivery_handle.rb +18 -16
  40. data/lib/rdkafka/producer/delivery_report.rb +51 -1
  41. data/lib/rdkafka/share_consumer.rb +54 -3
  42. data/lib/rdkafka/version.rb +3 -3
  43. data/lib/rdkafka.rb +10 -0
  44. data/package-lock.json +9 -9
  45. data/renovate.json +3 -0
  46. metadata +27 -2
data/lib/rdkafka/admin.rb CHANGED
@@ -520,6 +520,231 @@ module Rdkafka
520
520
  handle
521
521
  end
522
522
 
523
+ # Describes the cluster: its id, the current controller and the broker nodes (with racks).
524
+ #
525
+ # Unlike {#metadata}, this does not fetch any topic metadata.
526
+ #
527
+ # @param include_authorized_operations [Boolean] when true, also return the operations this
528
+ # client is authorized to perform on the cluster
529
+ # @return [DescribeClusterHandle] handle that can be used to wait for the result
530
+ # @raise [RdkafkaError] when describing the cluster fails
531
+ #
532
+ # @example Print the cluster id, the controller and every broker
533
+ # report = admin.describe_cluster.wait(max_wait_timeout_ms: 15_000)
534
+ #
535
+ # puts "cluster: #{report.cluster_id}, controller: #{report.controller[:id]}"
536
+ # report.nodes.each do |node|
537
+ # puts "#{node[:id]} #{node[:host]}:#{node[:port]} #{node[:rack]}"
538
+ # end
539
+ def describe_cluster(include_authorized_operations: false)
540
+ closed_admin_check(__method__)
541
+
542
+ queue_ptr = @native_kafka.with_inner do |inner|
543
+ Rdkafka::Bindings.rd_kafka_queue_get_background(inner)
544
+ end
545
+
546
+ if queue_ptr.null?
547
+ raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL")
548
+ end
549
+
550
+ handle = DescribeClusterHandle.new
551
+ handle[:pending] = true
552
+ handle[:response] = Rdkafka::Bindings::RD_KAFKA_PARTITION_UA
553
+ DescribeClusterHandle.register(handle)
554
+
555
+ admin_options_ptr = @native_kafka.with_inner do |inner|
556
+ Rdkafka::Bindings.rd_kafka_AdminOptions_new(
557
+ inner,
558
+ Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_DESCRIBECLUSTER
559
+ )
560
+ end
561
+ Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(admin_options_ptr, handle.to_ptr)
562
+
563
+ begin
564
+ set_include_authorized_operations(admin_options_ptr) if include_authorized_operations
565
+
566
+ @native_kafka.with_inner do |inner|
567
+ Rdkafka::Bindings.rd_kafka_DescribeCluster(
568
+ inner,
569
+ admin_options_ptr,
570
+ queue_ptr
571
+ )
572
+ end
573
+ rescue Exception
574
+ DescribeClusterHandle.remove(handle.to_ptr.address)
575
+ raise
576
+ ensure
577
+ Rdkafka::Bindings.rd_kafka_AdminOptions_destroy(admin_options_ptr)
578
+ Rdkafka::Bindings.rd_kafka_queue_destroy(queue_ptr)
579
+ end
580
+
581
+ handle
582
+ end
583
+
584
+ # Describes the given topics: their topic ids, partitions (leader, replicas and in-sync
585
+ # replicas, with racks) and, optionally, the operations this client is authorized to perform.
586
+ #
587
+ # A topic that cannot be described (e.g. it does not exist) does not fail the whole request;
588
+ # its entry in the report carries an `:error` instead.
589
+ #
590
+ # @param topic_names [Array<String>] names of the topics to describe
591
+ # @param include_authorized_operations [Boolean] when true, also return the operations this
592
+ # client is authorized to perform on each topic
593
+ # @return [DescribeTopicsHandle] handle that can be used to wait for the result
594
+ # @raise [ArgumentError] when topic_names is not an Array of Strings
595
+ # @raise [RdkafkaError] when describing the topics fails
596
+ #
597
+ # @example Print the topic id and partition leaders of a topic
598
+ # report = admin.describe_topics(["events"]).wait(max_wait_timeout_ms: 15_000)
599
+ #
600
+ # report.topics.each do |topic|
601
+ # next warn("#{topic[:name]}: #{topic[:error].message}") if topic[:error]
602
+ #
603
+ # puts "#{topic[:name]} (#{topic[:topic_id]})"
604
+ # topic[:partitions].each do |partition|
605
+ # puts " #{partition[:partition]} -> #{partition[:leader]&.fetch(:id)}"
606
+ # end
607
+ # end
608
+ def describe_topics(topic_names, include_authorized_operations: false)
609
+ closed_admin_check(__method__)
610
+
611
+ unless topic_names.is_a?(Array) && topic_names.all?(String)
612
+ raise ArgumentError, "topic_names must be an Array of Strings"
613
+ end
614
+
615
+ queue_ptr = @native_kafka.with_inner do |inner|
616
+ Rdkafka::Bindings.rd_kafka_queue_get_background(inner)
617
+ end
618
+
619
+ if queue_ptr.null?
620
+ raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL")
621
+ end
622
+
623
+ handle = DescribeTopicsHandle.new
624
+ handle[:pending] = true
625
+ handle[:response] = Rdkafka::Bindings::RD_KAFKA_PARTITION_UA
626
+ DescribeTopicsHandle.register(handle)
627
+
628
+ admin_options_ptr = @native_kafka.with_inner do |inner|
629
+ Rdkafka::Bindings.rd_kafka_AdminOptions_new(
630
+ inner,
631
+ Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_DESCRIBETOPICS
632
+ )
633
+ end
634
+ Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(admin_options_ptr, handle.to_ptr)
635
+
636
+ topic_collection_ptr = nil
637
+
638
+ begin
639
+ set_include_authorized_operations(admin_options_ptr) if include_authorized_operations
640
+
641
+ # librdkafka copies the names, so the Ruby-owned strings only need to outlive this call
642
+ name_ptrs = topic_names.map { |name| FFI::MemoryPointer.from_string(name) }
643
+ names_array_ptr = FFI::MemoryPointer.new(:pointer, [name_ptrs.size, 1].max)
644
+ names_array_ptr.write_array_of_pointer(name_ptrs)
645
+
646
+ topic_collection_ptr = Rdkafka::Bindings.rd_kafka_TopicCollection_of_topic_names(
647
+ names_array_ptr,
648
+ name_ptrs.size
649
+ )
650
+
651
+ @native_kafka.with_inner do |inner|
652
+ Rdkafka::Bindings.rd_kafka_DescribeTopics(
653
+ inner,
654
+ topic_collection_ptr,
655
+ admin_options_ptr,
656
+ queue_ptr
657
+ )
658
+ end
659
+ rescue Exception
660
+ DescribeTopicsHandle.remove(handle.to_ptr.address)
661
+ raise
662
+ ensure
663
+ Rdkafka::Bindings.rd_kafka_TopicCollection_destroy(topic_collection_ptr) if topic_collection_ptr
664
+ Rdkafka::Bindings.rd_kafka_AdminOptions_destroy(admin_options_ptr)
665
+ Rdkafka::Bindings.rd_kafka_queue_destroy(queue_ptr)
666
+ end
667
+
668
+ handle
669
+ end
670
+
671
+ # Describes the given consumer groups: their state, partition assignor, coordinator and
672
+ # members with their partition assignments.
673
+ #
674
+ # Each requested group is reported separately, with its own `:error`. A group id the cluster
675
+ # does not know is not an error: it is reported in the `Dead` state with no members.
676
+ #
677
+ # @param group_ids [Array<String>] ids of the consumer groups to describe
678
+ # @param include_authorized_operations [Boolean] whether to also fetch the ACL operations the
679
+ # client is authorized to perform on each group (reported as `:authorized_operations`)
680
+ # @return [DescribeConsumerGroupsHandle] handle that can be used to wait for the result
681
+ # @raise [RdkafkaError] when describing the consumer groups fails as a whole
682
+ #
683
+ # @example Describe a consumer group and print its members and their assignments
684
+ # report = admin.describe_consumer_groups(["example-group"]).wait(max_wait_timeout_ms: 15_000)
685
+ #
686
+ # report.groups.each do |group|
687
+ # next warn "#{group[:group_id]}: #{group[:error].message}" if group[:error]
688
+ #
689
+ # puts "#{group[:group_id]} - #{group[:state_name]} (#{group[:members].size} members)"
690
+ #
691
+ # group[:members].each do |member|
692
+ # puts " #{member[:client_id]}@#{member[:host]}: #{member[:assignment]}"
693
+ # end
694
+ # end
695
+ def describe_consumer_groups(group_ids, include_authorized_operations: false)
696
+ closed_admin_check(__method__)
697
+
698
+ group_id_ptrs = group_ids.map { |group_id| FFI::MemoryPointer.from_string(group_id) }
699
+ group_ids_ptr = FFI::MemoryPointer.new(:pointer, group_id_ptrs.size)
700
+ group_ids_ptr.write_array_of_pointer(group_id_ptrs)
701
+
702
+ # Get a pointer to the queue that our request will be enqueued on
703
+ queue_ptr = @native_kafka.with_inner do |inner|
704
+ Rdkafka::Bindings.rd_kafka_queue_get_background(inner)
705
+ end
706
+
707
+ if queue_ptr.null?
708
+ raise Rdkafka::Config::ConfigError.new("rd_kafka_queue_get_background was NULL")
709
+ end
710
+
711
+ # Create and register the handle we will return to the caller
712
+ handle = DescribeConsumerGroupsHandle.new
713
+ handle[:pending] = true
714
+ handle[:response] = Rdkafka::Bindings::RD_KAFKA_PARTITION_UA
715
+ DescribeConsumerGroupsHandle.register(handle)
716
+
717
+ admin_options_ptr = @native_kafka.with_inner do |inner|
718
+ Rdkafka::Bindings.rd_kafka_AdminOptions_new(
719
+ inner,
720
+ Rdkafka::Bindings::RD_KAFKA_ADMIN_OP_DESCRIBECONSUMERGROUPS
721
+ )
722
+ end
723
+ Rdkafka::Bindings.rd_kafka_AdminOptions_set_opaque(admin_options_ptr, handle.to_ptr)
724
+
725
+ begin
726
+ set_include_authorized_operations(admin_options_ptr) if include_authorized_operations
727
+
728
+ @native_kafka.with_inner do |inner|
729
+ Rdkafka::Bindings.rd_kafka_DescribeConsumerGroups(
730
+ inner,
731
+ group_ids_ptr,
732
+ group_id_ptrs.size,
733
+ admin_options_ptr,
734
+ queue_ptr
735
+ )
736
+ end
737
+ rescue Exception
738
+ DescribeConsumerGroupsHandle.remove(handle.to_ptr.address)
739
+ raise
740
+ ensure
741
+ Rdkafka::Bindings.rd_kafka_AdminOptions_destroy(admin_options_ptr)
742
+ Rdkafka::Bindings.rd_kafka_queue_destroy(queue_ptr)
743
+ end
744
+
745
+ handle
746
+ end
747
+
523
748
  # Deletes the named topic
524
749
  #
525
750
  # @param topic_name [String] name of the topic to delete
@@ -1254,6 +1479,26 @@ module Rdkafka
1254
1479
  handle
1255
1480
  end
1256
1481
 
1482
+ # Asks librdkafka to include authorized operations in a describe result
1483
+ # @param admin_options_ptr [FFI::Pointer] the admin options to update
1484
+ # @raise [RdkafkaError] when librdkafka rejects the option
1485
+ def set_include_authorized_operations(admin_options_ptr)
1486
+ error_ptr = Rdkafka::Bindings.rd_kafka_AdminOptions_set_include_authorized_operations(admin_options_ptr, 1)
1487
+
1488
+ return if error_ptr.null?
1489
+
1490
+ begin
1491
+ string_ptr = Rdkafka::Bindings.rd_kafka_error_string(error_ptr)
1492
+
1493
+ raise RdkafkaError.new(
1494
+ Rdkafka::Bindings.rd_kafka_error_code(error_ptr),
1495
+ broker_message: string_ptr.null? ? nil : string_ptr.read_string
1496
+ )
1497
+ ensure
1498
+ Rdkafka::Bindings.rd_kafka_error_destroy(error_ptr)
1499
+ end
1500
+ end
1501
+
1257
1502
  # Checks if the admin is closed and raises an error if so
1258
1503
  # @param method [Symbol] name of the calling method for error context
1259
1504
  # @raise [ClosedAdminError] when the admin is closed
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rdkafka
4
+ module Bindings
5
+ # Create Acls
6
+ RD_KAFKA_ADMIN_OP_CREATEACLS = 9
7
+ RD_KAFKA_EVENT_CREATEACLS_RESULT = 1024
8
+
9
+ attach_function :rd_kafka_CreateAcls, [:pointer, :pointer, :size_t, :pointer, :pointer], :void
10
+ attach_function :rd_kafka_event_CreateAcls_result, [:pointer], :pointer
11
+ attach_function :rd_kafka_CreateAcls_result_acls, [:pointer, :pointer], :pointer
12
+
13
+ # Delete Acls
14
+ RD_KAFKA_ADMIN_OP_DELETEACLS = 11
15
+ RD_KAFKA_EVENT_DELETEACLS_RESULT = 4096
16
+
17
+ attach_function :rd_kafka_DeleteAcls, [:pointer, :pointer, :size_t, :pointer, :pointer], :void
18
+ attach_function :rd_kafka_event_DeleteAcls_result, [:pointer], :pointer
19
+ attach_function :rd_kafka_DeleteAcls_result_responses, [:pointer, :pointer], :pointer
20
+ attach_function :rd_kafka_DeleteAcls_result_response_error, [:pointer], :pointer
21
+ attach_function :rd_kafka_DeleteAcls_result_response_matching_acls, [:pointer, :pointer], :pointer
22
+
23
+ # Describe Acls
24
+ RD_KAFKA_ADMIN_OP_DESCRIBEACLS = 10
25
+ RD_KAFKA_EVENT_DESCRIBEACLS_RESULT = 2048
26
+
27
+ attach_function :rd_kafka_DescribeAcls, [:pointer, :pointer, :pointer, :pointer], :void
28
+ attach_function :rd_kafka_event_DescribeAcls_result, [:pointer], :pointer
29
+ attach_function :rd_kafka_DescribeAcls_result_acls, [:pointer, :pointer], :pointer
30
+
31
+ # Acl Bindings
32
+
33
+ attach_function :rd_kafka_AclBinding_restype, [:pointer], :int32
34
+ attach_function :rd_kafka_AclBinding_name, [:pointer], :pointer
35
+ attach_function :rd_kafka_AclBinding_resource_pattern_type, [:pointer], :int32
36
+ attach_function :rd_kafka_AclBinding_principal, [:pointer], :pointer
37
+ attach_function :rd_kafka_AclBinding_host, [:pointer], :pointer
38
+ attach_function :rd_kafka_AclBinding_operation, [:pointer], :int32
39
+ attach_function :rd_kafka_AclBinding_permission_type, [:pointer], :int32
40
+ attach_function :rd_kafka_AclBinding_new, [:int32, :pointer, :int32, :pointer, :pointer, :int32, :int32, :pointer, :size_t], :pointer
41
+ attach_function :rd_kafka_AclBindingFilter_new, [:int32, :pointer, :int32, :pointer, :pointer, :int32, :int32, :pointer, :size_t], :pointer
42
+ attach_function :rd_kafka_AclBinding_destroy, [:pointer], :void
43
+
44
+ # rd_kafka_ResourceType_t -
45
+ # https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L7307
46
+ RD_KAFKA_RESOURCE_ANY = 1
47
+ RD_KAFKA_RESOURCE_TOPIC = 2
48
+ RD_KAFKA_RESOURCE_GROUP = 3
49
+ RD_KAFKA_RESOURCE_BROKER = 4
50
+ RD_KAFKA_RESOURCE_TRANSACTIONAL_ID = 5
51
+
52
+ # rd_kafka_ResourcePatternType_t -
53
+ # https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L7320
54
+ RD_KAFKA_RESOURCE_PATTERN_UNKNOWN = 0
55
+ RD_KAFKA_RESOURCE_PATTERN_ANY = 1
56
+ RD_KAFKA_RESOURCE_PATTERN_MATCH = 2
57
+ RD_KAFKA_RESOURCE_PATTERN_LITERAL = 3
58
+ RD_KAFKA_RESOURCE_PATTERN_PREFIXED = 4
59
+
60
+ # rd_kafka_AclOperation_t -
61
+ # https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L8403
62
+ RD_KAFKA_ACL_OPERATION_ANY = 1
63
+ RD_KAFKA_ACL_OPERATION_ALL = 2
64
+ RD_KAFKA_ACL_OPERATION_READ = 3
65
+ RD_KAFKA_ACL_OPERATION_WRITE = 4
66
+ RD_KAFKA_ACL_OPERATION_CREATE = 5
67
+ RD_KAFKA_ACL_OPERATION_DELETE = 6
68
+ RD_KAFKA_ACL_OPERATION_ALTER = 7
69
+ RD_KAFKA_ACL_OPERATION_DESCRIBE = 8
70
+ RD_KAFKA_ACL_OPERATION_CLUSTER_ACTION = 9
71
+ RD_KAFKA_ACL_OPERATION_DESCRIBE_CONFIGS = 10
72
+ RD_KAFKA_ACL_OPERATION_ALTER_CONFIGS = 11
73
+ RD_KAFKA_ACL_OPERATION_IDEMPOTENT_WRITE = 12
74
+
75
+ # rd_kafka_AclPermissionType_t -
76
+ # https://github.com/confluentinc/librdkafka/blob/292d2a66b992/src/rdkafka.h#L8435
77
+ RD_KAFKA_ACL_PERMISSION_TYPE_ANY = 1
78
+ RD_KAFKA_ACL_PERMISSION_TYPE_DENY = 2
79
+ RD_KAFKA_ACL_PERMISSION_TYPE_ALLOW = 3
80
+
81
+ # Extracting error details from Acl results
82
+ attach_function :rd_kafka_acl_result_error, [:pointer], :pointer
83
+ attach_function :rd_kafka_AclBinding_error, [:pointer], :pointer
84
+ end
85
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rdkafka
4
+ module Bindings
5
+ attach_function :rd_kafka_DescribeConfigs, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
6
+ attach_function :rd_kafka_ConfigResource_new, [:int32, :pointer], :pointer
7
+ attach_function :rd_kafka_ConfigResource_destroy, [:pointer], :void
8
+ attach_function :rd_kafka_ConfigResource_destroy_array, [:pointer, :int32], :void
9
+ attach_function :rd_kafka_event_DescribeConfigs_result, [:pointer], :pointer
10
+ attach_function :rd_kafka_DescribeConfigs_result_resources, [:pointer, :pointer], :pointer
11
+ attach_function :rd_kafka_ConfigResource_configs, [:pointer, :pointer], :pointer
12
+ attach_function :rd_kafka_ConfigEntry_name, [:pointer], :string
13
+ attach_function :rd_kafka_ConfigEntry_value, [:pointer], :string
14
+ attach_function :rd_kafka_ConfigEntry_is_read_only, [:pointer], :int
15
+ attach_function :rd_kafka_ConfigEntry_is_default, [:pointer], :int
16
+ attach_function :rd_kafka_ConfigEntry_is_sensitive, [:pointer], :int
17
+ attach_function :rd_kafka_ConfigEntry_is_synonym, [:pointer], :int
18
+ attach_function :rd_kafka_ConfigEntry_synonyms, [:pointer, :pointer], :pointer
19
+ attach_function :rd_kafka_ConfigResource_error, [:pointer], :int
20
+ attach_function :rd_kafka_ConfigResource_error_string, [:pointer], :string
21
+ attach_function :rd_kafka_IncrementalAlterConfigs, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
22
+ attach_function :rd_kafka_IncrementalAlterConfigs_result_resources, [:pointer, :pointer], :pointer
23
+ attach_function :rd_kafka_ConfigResource_add_incremental_config, [:pointer, :string, :int32, :string], :pointer
24
+ attach_function :rd_kafka_event_IncrementalAlterConfigs_result, [:pointer], :pointer
25
+
26
+ RD_KAFKA_ADMIN_OP_DESCRIBECONFIGS = 5
27
+ RD_KAFKA_EVENT_DESCRIBECONFIGS_RESULT = 104
28
+
29
+ RD_KAFKA_ADMIN_OP_INCREMENTALALTERCONFIGS = 16
30
+ RD_KAFKA_EVENT_INCREMENTALALTERCONFIGS_RESULT = 131072
31
+
32
+ RD_KAFKA_ALTER_CONFIG_OP_TYPE_SET = 0
33
+ RD_KAFKA_ALTER_CONFIG_OP_TYPE_DELETE = 1
34
+ RD_KAFKA_ALTER_CONFIG_OP_TYPE_APPEND = 2
35
+ RD_KAFKA_ALTER_CONFIG_OP_TYPE_SUBTRACT = 3
36
+ end
37
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rdkafka
4
+ module Bindings
5
+ # List Offsets
6
+ RD_KAFKA_ADMIN_OP_LISTOFFSETS = 21
7
+ RD_KAFKA_EVENT_LISTOFFSETS_RESULT = 0x400000
8
+
9
+ # rd_kafka_IsolationLevel_t
10
+ RD_KAFKA_ISOLATION_LEVEL_READ_UNCOMMITTED = 0
11
+ RD_KAFKA_ISOLATION_LEVEL_READ_COMMITTED = 1
12
+
13
+ # rd_kafka_OffsetSpec_t
14
+ RD_KAFKA_OFFSET_SPEC_MAX_TIMESTAMP = -3
15
+ RD_KAFKA_OFFSET_SPEC_EARLIEST = -2
16
+ RD_KAFKA_OFFSET_SPEC_LATEST = -1
17
+
18
+ attach_function :rd_kafka_ListOffsets, [:pointer, :pointer, :pointer, :pointer], :void, blocking: true
19
+ attach_function :rd_kafka_event_ListOffsets_result, [:pointer], :pointer
20
+ attach_function :rd_kafka_ListOffsets_result_infos, [:pointer, :pointer], :pointer
21
+ attach_function :rd_kafka_ListOffsetsResultInfo_topic_partition, [:pointer], :pointer
22
+ attach_function :rd_kafka_ListOffsetsResultInfo_timestamp, [:pointer], :int64
23
+ attach_function :rd_kafka_AdminOptions_set_isolation_level, [:pointer, :int], :pointer
24
+ attach_function :rd_kafka_topic_partition_get_leader_epoch, [:pointer], :int32
25
+ end
26
+ end
@@ -0,0 +1,197 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rdkafka
4
+ module Bindings
5
+ # Create Topics
6
+ RD_KAFKA_ADMIN_OP_CREATETOPICS = 1 # rd_kafka_admin_op_t
7
+ RD_KAFKA_EVENT_CREATETOPICS_RESULT = 100 # rd_kafka_event_type_t
8
+
9
+ attach_function :rd_kafka_CreateTopics, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
10
+ attach_function :rd_kafka_NewTopic_new, [:pointer, :size_t, :size_t, :pointer, :size_t], :pointer, blocking: true
11
+ attach_function :rd_kafka_NewTopic_set_config, [:pointer, :string, :string], :int32, blocking: true
12
+ attach_function :rd_kafka_NewTopic_destroy, [:pointer], :void, blocking: true
13
+ attach_function :rd_kafka_event_CreateTopics_result, [:pointer], :pointer, blocking: true
14
+ attach_function :rd_kafka_CreateTopics_result_topics, [:pointer, :pointer], :pointer, blocking: true
15
+
16
+ # Delete Topics
17
+ RD_KAFKA_ADMIN_OP_DELETETOPICS = 2 # rd_kafka_admin_op_t
18
+ RD_KAFKA_EVENT_DELETETOPICS_RESULT = 101 # rd_kafka_event_type_t
19
+
20
+ attach_function :rd_kafka_DeleteTopics, [:pointer, :pointer, :size_t, :pointer, :pointer], :int32, blocking: true
21
+ attach_function :rd_kafka_DeleteTopic_new, [:pointer], :pointer, blocking: true
22
+ attach_function :rd_kafka_DeleteTopic_destroy, [:pointer], :void, blocking: true
23
+ attach_function :rd_kafka_event_DeleteTopics_result, [:pointer], :pointer, blocking: true
24
+ attach_function :rd_kafka_DeleteTopics_result_topics, [:pointer, :pointer], :pointer, blocking: true
25
+
26
+ # Create partitions
27
+ RD_KAFKA_ADMIN_OP_CREATEPARTITIONS = 3
28
+ RD_KAFKA_ADMIN_OP_CREATEPARTITIONS_RESULT = 102
29
+
30
+ attach_function :rd_kafka_CreatePartitions, [:pointer, :pointer, :size_t, :pointer, :pointer], :void
31
+ attach_function :rd_kafka_NewPartitions_new, %i[pointer size_t pointer size_t], :pointer
32
+ attach_function :rd_kafka_NewPartitions_destroy, [:pointer], :void
33
+ attach_function :rd_kafka_event_CreatePartitions_result, [:pointer], :pointer
34
+ attach_function :rd_kafka_CreatePartitions_result_topics, [:pointer, :pointer], :pointer
35
+
36
+ # Delete Group
37
+ RD_KAFKA_ADMIN_OP_DELETEGROUPS = 7 # rd_kafka_admin_op_t
38
+ RD_KAFKA_EVENT_DELETEGROUPS_RESULT = 106 # rd_kafka_event_type_t
39
+
40
+ attach_function :rd_kafka_DeleteGroups, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
41
+ attach_function :rd_kafka_DeleteGroup_new, [:pointer], :pointer, blocking: true
42
+ attach_function :rd_kafka_DeleteGroup_destroy, [:pointer], :void, blocking: true
43
+ attach_function :rd_kafka_event_DeleteGroups_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DeleteGroups_result_t*
44
+ attach_function :rd_kafka_DeleteGroups_result_groups, [:pointer, :pointer], :pointer, blocking: true # rd_kafka_DeleteGroups_result_t*, size_t* => rd_kafka_group_result_t**
45
+
46
+ # Alter Consumer Group Offsets
47
+ RD_KAFKA_ADMIN_OP_ALTERCONSUMERGROUPOFFSETS = 15 # rd_kafka_admin_op_t
48
+ RD_KAFKA_EVENT_ALTERCONSUMERGROUPOFFSETS_RESULT = 0x10000 # rd_kafka_event_type_t
49
+
50
+ attach_function :rd_kafka_AlterConsumerGroupOffsets, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
51
+ attach_function :rd_kafka_AlterConsumerGroupOffsets_new, [:pointer, :pointer], :pointer, blocking: true # const char*, const rd_kafka_topic_partition_list_t* => rd_kafka_AlterConsumerGroupOffsets_t*
52
+ attach_function :rd_kafka_AlterConsumerGroupOffsets_destroy, [:pointer], :void, blocking: true
53
+ attach_function :rd_kafka_event_AlterConsumerGroupOffsets_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_AlterConsumerGroupOffsets_result_t*
54
+ attach_function :rd_kafka_AlterConsumerGroupOffsets_result_groups, [:pointer, :pointer], :pointer, blocking: true # rd_kafka_AlterConsumerGroupOffsets_result_t*, size_t* => rd_kafka_group_result_t**
55
+
56
+ # Delete Consumer Group Offsets
57
+ RD_KAFKA_ADMIN_OP_DELETECONSUMERGROUPOFFSETS = 8 # rd_kafka_admin_op_t
58
+ RD_KAFKA_EVENT_DELETECONSUMERGROUPOFFSETS_RESULT = 107 # rd_kafka_event_type_t
59
+
60
+ attach_function :rd_kafka_DeleteConsumerGroupOffsets, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
61
+ attach_function :rd_kafka_DeleteConsumerGroupOffsets_new, [:pointer, :pointer], :pointer, blocking: true # const char*, const rd_kafka_topic_partition_list_t* => rd_kafka_DeleteConsumerGroupOffsets_t*
62
+ attach_function :rd_kafka_DeleteConsumerGroupOffsets_destroy, [:pointer], :void, blocking: true
63
+ attach_function :rd_kafka_event_DeleteConsumerGroupOffsets_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DeleteConsumerGroupOffsets_result_t*
64
+ attach_function :rd_kafka_DeleteConsumerGroupOffsets_result_groups, [:pointer, :pointer], :pointer, blocking: true # rd_kafka_DeleteConsumerGroupOffsets_result_t*, size_t* => rd_kafka_group_result_t**
65
+
66
+ # Delete Records
67
+ RD_KAFKA_ADMIN_OP_DELETERECORDS = 6 # rd_kafka_admin_op_t
68
+ RD_KAFKA_EVENT_DELETERECORDS_RESULT = 105 # rd_kafka_event_type_t
69
+
70
+ attach_function :rd_kafka_DeleteRecords, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
71
+ attach_function :rd_kafka_DeleteRecords_new, [:pointer], :pointer, blocking: true
72
+ attach_function :rd_kafka_DeleteRecords_destroy, [:pointer], :void, blocking: true
73
+ attach_function :rd_kafka_event_DeleteRecords_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DeleteRecords_result_t*
74
+ attach_function :rd_kafka_DeleteRecords_result_offsets, [:pointer], :pointer, blocking: true # rd_kafka_DeleteRecords_result_t* => rd_kafka_topic_partition_list_t*
75
+
76
+ # List Consumer Groups
77
+ RD_KAFKA_ADMIN_OP_LISTCONSUMERGROUPS = 12 # rd_kafka_admin_op_t
78
+ RD_KAFKA_EVENT_LISTCONSUMERGROUPS_RESULT = 0x2000 # rd_kafka_event_type_t
79
+
80
+ # Consumer group states (rd_kafka_consumer_group_state_t)
81
+ RD_KAFKA_CONSUMER_GROUP_STATE_UNKNOWN = 0
82
+ RD_KAFKA_CONSUMER_GROUP_STATE_PREPARING_REBALANCE = 1
83
+ RD_KAFKA_CONSUMER_GROUP_STATE_COMPLETING_REBALANCE = 2
84
+ RD_KAFKA_CONSUMER_GROUP_STATE_STABLE = 3
85
+ RD_KAFKA_CONSUMER_GROUP_STATE_DEAD = 4
86
+ RD_KAFKA_CONSUMER_GROUP_STATE_EMPTY = 5
87
+
88
+ attach_function :rd_kafka_ListConsumerGroups, [:pointer, :pointer, :pointer], :void, blocking: true
89
+ attach_function :rd_kafka_event_ListConsumerGroups_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_ListConsumerGroups_result_t*
90
+ attach_function :rd_kafka_ListConsumerGroups_result_valid, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_ConsumerGroupListing_t**
91
+ attach_function :rd_kafka_ListConsumerGroups_result_errors, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_error_t**
92
+ attach_function :rd_kafka_ConsumerGroupListing_group_id, [:pointer], :pointer, blocking: true # => const char*
93
+ attach_function :rd_kafka_ConsumerGroupListing_is_simple_consumer_group, [:pointer], :int, blocking: true
94
+ attach_function :rd_kafka_ConsumerGroupListing_state, [:pointer], :int, blocking: true
95
+ attach_function :rd_kafka_consumer_group_state_name, [:int], :pointer, blocking: true # => const char*
96
+
97
+ # Describe Consumer Groups
98
+ RD_KAFKA_ADMIN_OP_DESCRIBECONSUMERGROUPS = 13 # rd_kafka_admin_op_t
99
+ RD_KAFKA_EVENT_DESCRIBECONSUMERGROUPS_RESULT = 0x4000 # rd_kafka_event_type_t
100
+
101
+ # Consumer group types (rd_kafka_consumer_group_type_t)
102
+ RD_KAFKA_CONSUMER_GROUP_TYPE_UNKNOWN = 0
103
+ RD_KAFKA_CONSUMER_GROUP_TYPE_CONSUMER = 1
104
+ RD_KAFKA_CONSUMER_GROUP_TYPE_CLASSIC = 2
105
+
106
+ attach_function :rd_kafka_DescribeConsumerGroups, [:pointer, :pointer, :size_t, :pointer, :pointer], :void, blocking: true
107
+ attach_function :rd_kafka_event_DescribeConsumerGroups_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DescribeConsumerGroups_result_t*
108
+ attach_function :rd_kafka_DescribeConsumerGroups_result_groups, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_ConsumerGroupDescription_t**
109
+ attach_function :rd_kafka_ConsumerGroupDescription_group_id, [:pointer], :pointer, blocking: true # => const char*
110
+ attach_function :rd_kafka_ConsumerGroupDescription_error, [:pointer], :pointer, blocking: true # => const rd_kafka_error_t*
111
+ attach_function :rd_kafka_ConsumerGroupDescription_is_simple_consumer_group, [:pointer], :int, blocking: true
112
+ attach_function :rd_kafka_ConsumerGroupDescription_partition_assignor, [:pointer], :pointer, blocking: true # => const char*
113
+ attach_function :rd_kafka_ConsumerGroupDescription_state, [:pointer], :int, blocking: true
114
+ attach_function :rd_kafka_ConsumerGroupDescription_type, [:pointer], :int, blocking: true
115
+ attach_function :rd_kafka_ConsumerGroupDescription_authorized_operations, [:pointer, :pointer], :pointer, blocking: true # grpdesc*, size_t* => const rd_kafka_AclOperation_t*
116
+ attach_function :rd_kafka_ConsumerGroupDescription_coordinator, [:pointer], :pointer, blocking: true # => const rd_kafka_Node_t*
117
+ attach_function :rd_kafka_ConsumerGroupDescription_member_count, [:pointer], :size_t, blocking: true
118
+ attach_function :rd_kafka_ConsumerGroupDescription_member, [:pointer, :size_t], :pointer, blocking: true # => const rd_kafka_MemberDescription_t*
119
+ attach_function :rd_kafka_MemberDescription_client_id, [:pointer], :pointer, blocking: true # => const char*
120
+ attach_function :rd_kafka_MemberDescription_group_instance_id, [:pointer], :pointer, blocking: true # => const char*
121
+ attach_function :rd_kafka_MemberDescription_consumer_id, [:pointer], :pointer, blocking: true # => const char*
122
+ attach_function :rd_kafka_MemberDescription_host, [:pointer], :pointer, blocking: true # => const char*
123
+ attach_function :rd_kafka_MemberDescription_assignment, [:pointer], :pointer, blocking: true # => const rd_kafka_MemberAssignment_t*
124
+ attach_function :rd_kafka_MemberDescription_target_assignment, [:pointer], :pointer, blocking: true # => const rd_kafka_MemberAssignment_t*
125
+ attach_function :rd_kafka_MemberAssignment_partitions, [:pointer], :pointer, blocking: true # => const rd_kafka_topic_partition_list_t*
126
+ attach_function :rd_kafka_consumer_group_type_name, [:int], :pointer, blocking: true # => const char*
127
+
128
+ # Describe Topics and Describe Cluster
129
+ RD_KAFKA_ADMIN_OP_DESCRIBETOPICS = 19 # rd_kafka_admin_op_t
130
+ RD_KAFKA_EVENT_DESCRIBETOPICS_RESULT = 0x100000 # rd_kafka_event_type_t
131
+ RD_KAFKA_ADMIN_OP_DESCRIBECLUSTER = 20 # rd_kafka_admin_op_t
132
+ RD_KAFKA_EVENT_DESCRIBECLUSTER_RESULT = 0x200000 # rd_kafka_event_type_t
133
+
134
+ attach_function :rd_kafka_AdminOptions_set_include_authorized_operations, [:pointer, :int], :pointer, blocking: true # => rd_kafka_error_t*
135
+ attach_function :rd_kafka_TopicCollection_of_topic_names, [:pointer, :size_t], :pointer, blocking: true # const char**, size_t => rd_kafka_TopicCollection_t*
136
+ attach_function :rd_kafka_TopicCollection_destroy, [:pointer], :void, blocking: true
137
+ attach_function :rd_kafka_DescribeTopics, [:pointer, :pointer, :pointer, :pointer], :void, blocking: true
138
+ attach_function :rd_kafka_event_DescribeTopics_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DescribeTopics_result_t*
139
+ attach_function :rd_kafka_DescribeTopics_result_topics, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_TopicDescription_t**
140
+ attach_function :rd_kafka_TopicDescription_name, [:pointer], :pointer, blocking: true # => const char*
141
+ attach_function :rd_kafka_TopicDescription_topic_id, [:pointer], :pointer, blocking: true # => rd_kafka_Uuid_t*
142
+ attach_function :rd_kafka_TopicDescription_is_internal, [:pointer], :int, blocking: true
143
+ attach_function :rd_kafka_TopicDescription_partitions, [:pointer, :pointer], :pointer, blocking: true # desc*, size_t* => rd_kafka_TopicPartitionInfo_t**
144
+ attach_function :rd_kafka_TopicDescription_authorized_operations, [:pointer, :pointer], :pointer, blocking: true # desc*, size_t* => rd_kafka_AclOperation_t*
145
+ attach_function :rd_kafka_TopicDescription_error, [:pointer], :pointer, blocking: true # => rd_kafka_error_t*
146
+ attach_function :rd_kafka_TopicPartitionInfo_partition, [:pointer], :int, blocking: true
147
+ attach_function :rd_kafka_TopicPartitionInfo_leader, [:pointer], :pointer, blocking: true # => rd_kafka_Node_t*
148
+ attach_function :rd_kafka_TopicPartitionInfo_replicas, [:pointer, :pointer], :pointer, blocking: true # info*, size_t* => rd_kafka_Node_t**
149
+ attach_function :rd_kafka_TopicPartitionInfo_isr, [:pointer, :pointer], :pointer, blocking: true # info*, size_t* => rd_kafka_Node_t**
150
+ attach_function :rd_kafka_Uuid_base64str, [:pointer], :pointer, blocking: true # => const char*
151
+ attach_function :rd_kafka_Uuid_most_significant_bits, [:pointer], :int64, blocking: true
152
+ attach_function :rd_kafka_Uuid_least_significant_bits, [:pointer], :int64, blocking: true
153
+ attach_function :rd_kafka_DescribeCluster, [:pointer, :pointer, :pointer], :void, blocking: true
154
+ attach_function :rd_kafka_event_DescribeCluster_result, [:pointer], :pointer, blocking: true # rd_kafka_event_t* => rd_kafka_DescribeCluster_result_t*
155
+ attach_function :rd_kafka_DescribeCluster_result_nodes, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_Node_t**
156
+ attach_function :rd_kafka_DescribeCluster_result_controller, [:pointer], :pointer, blocking: true # => rd_kafka_Node_t*
157
+ attach_function :rd_kafka_DescribeCluster_result_cluster_id, [:pointer], :pointer, blocking: true # => const char*
158
+ attach_function :rd_kafka_DescribeCluster_result_authorized_operations, [:pointer, :pointer], :pointer, blocking: true # result*, size_t* => rd_kafka_AclOperation_t*
159
+ attach_function :rd_kafka_Node_id, [:pointer], :int, blocking: true
160
+ attach_function :rd_kafka_Node_host, [:pointer], :pointer, blocking: true # => const char*
161
+ attach_function :rd_kafka_Node_port, [:pointer], :uint16, blocking: true
162
+ attach_function :rd_kafka_Node_rack, [:pointer], :pointer, blocking: true # => const char*
163
+
164
+ # Background Queue and Callback
165
+
166
+ attach_function :rd_kafka_conf_set_background_event_cb, [:pointer, :pointer], :void
167
+ attach_function :rd_kafka_queue_destroy, [:pointer], :void
168
+
169
+ # Admin Options
170
+
171
+ attach_function :rd_kafka_AdminOptions_new, [:pointer, :int32], :pointer
172
+ attach_function :rd_kafka_AdminOptions_set_opaque, [:pointer, :pointer], :void
173
+ attach_function :rd_kafka_AdminOptions_destroy, [:pointer], :void
174
+
175
+ # Extracting data from event types
176
+
177
+ attach_function :rd_kafka_event_type, [:pointer], :int32
178
+ attach_function :rd_kafka_event_opaque, [:pointer], :pointer
179
+ attach_function :rd_kafka_event_destroy, [:pointer], :void
180
+ attach_function :rd_kafka_event_error, [:pointer], :int32
181
+ attach_function :rd_kafka_event_error_string, [:pointer], :pointer
182
+
183
+ # Extracting data from topic results
184
+
185
+ attach_function :rd_kafka_topic_result_error, [:pointer], :int32
186
+ attach_function :rd_kafka_topic_result_error_string, [:pointer], :pointer
187
+ attach_function :rd_kafka_topic_result_name, [:pointer], :pointer
188
+
189
+ attach_function :rd_kafka_group_result_error, [:pointer], NativeError.by_ref # rd_kafka_group_result_t* => rd_kafka_error_t*
190
+ attach_function :rd_kafka_group_result_name, [:pointer], :pointer
191
+ attach_function :rd_kafka_group_result_partitions, [:pointer], :pointer # rd_kafka_group_result_t* => rd_kafka_topic_partition_list_t*
192
+ end
193
+ end
194
+
195
+ require_relative "admin/configs"
196
+ require_relative "admin/list_offsets"
197
+ require_relative "admin/acls"