rdkafka 0.13.0 → 0.31.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +388 -111
- data/{LICENSE → MIT-LICENSE} +2 -1
- data/README.md +90 -43
- data/Rakefile +21 -23
- data/bin/verify_kafka_warnings +44 -0
- data/dist/librdkafka-2.15.1.tar.gz +0 -0
- data/dist/patches/rdkafka_global_init.patch +15 -0
- data/docker-compose-ssl.yml +39 -0
- data/docker-compose.yml +22 -17
- data/ext/Rakefile +97 -30
- data/lib/rdkafka/abstract_handle.rb +113 -34
- data/lib/rdkafka/admin/acl_binding_result.rb +51 -0
- data/lib/rdkafka/admin/alter_consumer_group_offsets_handle.rb +31 -0
- data/lib/rdkafka/admin/alter_consumer_group_offsets_report.rb +50 -0
- data/lib/rdkafka/admin/config_binding_result.rb +30 -0
- data/lib/rdkafka/admin/config_resource_binding_result.rb +19 -0
- data/lib/rdkafka/admin/create_acl_handle.rb +32 -0
- data/lib/rdkafka/admin/create_acl_report.rb +26 -0
- data/lib/rdkafka/admin/create_partitions_handle.rb +28 -0
- data/lib/rdkafka/admin/create_partitions_report.rb +7 -0
- data/lib/rdkafka/admin/create_topic_handle.rb +8 -7
- data/lib/rdkafka/admin/create_topic_report.rb +4 -1
- data/lib/rdkafka/admin/delete_acl_handle.rb +31 -0
- data/lib/rdkafka/admin/delete_acl_report.rb +25 -0
- data/lib/rdkafka/admin/delete_consumer_group_offsets_handle.rb +31 -0
- data/lib/rdkafka/admin/delete_consumer_group_offsets_report.rb +50 -0
- data/lib/rdkafka/admin/delete_groups_handle.rb +31 -0
- data/lib/rdkafka/admin/delete_groups_report.rb +27 -0
- data/lib/rdkafka/admin/delete_records_handle.rb +31 -0
- data/lib/rdkafka/admin/delete_records_report.rb +25 -0
- data/lib/rdkafka/admin/delete_topic_handle.rb +8 -7
- data/lib/rdkafka/admin/delete_topic_report.rb +4 -1
- data/lib/rdkafka/admin/describe_acl_handle.rb +31 -0
- data/lib/rdkafka/admin/describe_acl_report.rb +27 -0
- data/lib/rdkafka/admin/describe_cluster_handle.rb +31 -0
- data/lib/rdkafka/admin/describe_cluster_report.rb +48 -0
- data/lib/rdkafka/admin/describe_configs_handle.rb +30 -0
- data/lib/rdkafka/admin/describe_configs_report.rb +56 -0
- data/lib/rdkafka/admin/describe_consumer_groups_handle.rb +31 -0
- data/lib/rdkafka/admin/describe_consumer_groups_report.rb +151 -0
- data/lib/rdkafka/admin/describe_result_parsing.rb +47 -0
- data/lib/rdkafka/admin/describe_topics_handle.rb +31 -0
- data/lib/rdkafka/admin/describe_topics_report.rb +118 -0
- data/lib/rdkafka/admin/incremental_alter_configs_handle.rb +30 -0
- data/lib/rdkafka/admin/incremental_alter_configs_report.rb +56 -0
- data/lib/rdkafka/admin/list_consumer_groups_handle.rb +31 -0
- data/lib/rdkafka/admin/list_consumer_groups_report.rb +83 -0
- data/lib/rdkafka/admin/list_offsets_handle.rb +31 -0
- data/lib/rdkafka/admin/list_offsets_report.rb +54 -0
- data/lib/rdkafka/admin.rb +1381 -38
- data/lib/rdkafka/bindings/admin/acls.rb +85 -0
- data/lib/rdkafka/bindings/admin/configs.rb +37 -0
- data/lib/rdkafka/bindings/admin/list_offsets.rb +26 -0
- data/lib/rdkafka/bindings/admin.rb +197 -0
- data/lib/rdkafka/bindings/callbacks.rb +100 -0
- data/lib/rdkafka/bindings/configuration.rb +50 -0
- data/lib/rdkafka/bindings/consumer.rb +83 -0
- data/lib/rdkafka/bindings/errors.rb +15 -0
- data/lib/rdkafka/bindings/handle.rb +16 -0
- data/lib/rdkafka/bindings/messages.rb +28 -0
- data/lib/rdkafka/bindings/metadata.rb +14 -0
- data/lib/rdkafka/bindings/polling.rb +17 -0
- data/lib/rdkafka/bindings/producer.rb +77 -0
- data/lib/rdkafka/bindings/structs.rb +62 -0
- data/lib/rdkafka/bindings.rb +69 -294
- data/lib/rdkafka/callbacks/alter_consumer_group_offsets_handler.rb +65 -0
- data/lib/rdkafka/callbacks/base_handler.rb +62 -0
- data/lib/rdkafka/callbacks/create_acl_handler.rb +37 -0
- data/lib/rdkafka/callbacks/create_partitions_handler.rb +37 -0
- data/lib/rdkafka/callbacks/create_topic_handler.rb +37 -0
- data/lib/rdkafka/callbacks/delete_acl_handler.rb +42 -0
- data/lib/rdkafka/callbacks/delete_consumer_group_offsets_handler.rb +65 -0
- data/lib/rdkafka/callbacks/delete_groups_handler.rb +37 -0
- data/lib/rdkafka/callbacks/delete_records_handler.rb +38 -0
- data/lib/rdkafka/callbacks/delete_topic_handler.rb +37 -0
- data/lib/rdkafka/callbacks/describe_acl_handler.rb +35 -0
- data/lib/rdkafka/callbacks/describe_cluster_handler.rb +36 -0
- data/lib/rdkafka/callbacks/describe_configs_handler.rb +42 -0
- data/lib/rdkafka/callbacks/describe_consumer_groups_handler.rb +36 -0
- data/lib/rdkafka/callbacks/describe_topics_handler.rb +36 -0
- data/lib/rdkafka/callbacks/incremental_alter_configs_handler.rb +42 -0
- data/lib/rdkafka/callbacks/list_consumer_groups_handler.rb +39 -0
- data/lib/rdkafka/callbacks/list_offsets_handler.rb +42 -0
- data/lib/rdkafka/callbacks.rb +273 -52
- data/lib/rdkafka/clients.rb +81 -0
- data/lib/rdkafka/config.rb +333 -91
- data/lib/rdkafka/consumer/allocator.rb +38 -0
- data/lib/rdkafka/consumer/headers.rb +39 -25
- data/lib/rdkafka/consumer/message.rb +18 -20
- data/lib/rdkafka/consumer/partition.rb +15 -4
- data/lib/rdkafka/consumer/topic_partition_list.rb +82 -48
- data/lib/rdkafka/consumer.rb +765 -192
- data/lib/rdkafka/defaults.rb +123 -0
- data/lib/rdkafka/error.rb +40 -14
- data/lib/rdkafka/helpers/list_offsets.rb +127 -0
- data/lib/rdkafka/helpers/metadata.rb +29 -0
- data/lib/rdkafka/helpers/oauth.rb +95 -0
- data/lib/rdkafka/helpers/time.rb +19 -0
- data/lib/rdkafka/metadata.rb +138 -26
- data/lib/rdkafka/native_kafka.rb +142 -22
- data/lib/rdkafka/producer/delivery_handle.rb +27 -7
- data/lib/rdkafka/producer/delivery_report.rb +71 -4
- data/lib/rdkafka/producer/partitions_count_cache.rb +212 -0
- data/lib/rdkafka/producer.rb +422 -81
- data/lib/rdkafka/version.rb +6 -3
- data/lib/rdkafka.rb +73 -1
- data/package-lock.json +331 -0
- data/package.json +9 -0
- data/rdkafka.gemspec +78 -25
- data/renovate.json +111 -0
- metadata +114 -134
- data/.gitignore +0 -8
- data/.rspec +0 -1
- data/.semaphore/semaphore.yml +0 -27
- data/.yardopts +0 -2
- data/Gemfile +0 -5
- data/Guardfile +0 -19
- data/ext/README.md +0 -18
- data/spec/rdkafka/abstract_handle_spec.rb +0 -115
- data/spec/rdkafka/admin/create_topic_handle_spec.rb +0 -54
- data/spec/rdkafka/admin/create_topic_report_spec.rb +0 -18
- data/spec/rdkafka/admin/delete_topic_handle_spec.rb +0 -54
- data/spec/rdkafka/admin/delete_topic_report_spec.rb +0 -18
- data/spec/rdkafka/admin_spec.rb +0 -204
- data/spec/rdkafka/bindings_spec.rb +0 -136
- data/spec/rdkafka/callbacks_spec.rb +0 -22
- data/spec/rdkafka/config_spec.rb +0 -197
- data/spec/rdkafka/consumer/headers_spec.rb +0 -62
- data/spec/rdkafka/consumer/message_spec.rb +0 -141
- data/spec/rdkafka/consumer/partition_spec.rb +0 -59
- data/spec/rdkafka/consumer/topic_partition_list_spec.rb +0 -225
- data/spec/rdkafka/consumer_spec.rb +0 -1106
- data/spec/rdkafka/error_spec.rb +0 -91
- data/spec/rdkafka/metadata_spec.rb +0 -80
- data/spec/rdkafka/native_kafka_spec.rb +0 -124
- data/spec/rdkafka/producer/delivery_handle_spec.rb +0 -47
- data/spec/rdkafka/producer/delivery_report_spec.rb +0 -23
- data/spec/rdkafka/producer_spec.rb +0 -557
- data/spec/spec_helper.rb +0 -155
|
@@ -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"
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Bindings
|
|
5
|
+
LogCallback = FFI::Function.new(
|
|
6
|
+
:void, [:pointer, :int, :string, :string]
|
|
7
|
+
) do |_client_ptr, level, _level_string, line|
|
|
8
|
+
severity = case level
|
|
9
|
+
when 0, 1, 2
|
|
10
|
+
Logger::FATAL
|
|
11
|
+
when 3
|
|
12
|
+
Logger::ERROR
|
|
13
|
+
when 4
|
|
14
|
+
Logger::WARN
|
|
15
|
+
when 5, 6
|
|
16
|
+
Logger::INFO
|
|
17
|
+
when 7
|
|
18
|
+
Logger::DEBUG
|
|
19
|
+
else
|
|
20
|
+
Logger::UNKNOWN
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Rdkafka::Config.ensure_log_thread
|
|
24
|
+
Rdkafka::Config.log_queue << [severity, "rdkafka: #{line}"]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
StatsCallback = FFI::Function.new(
|
|
28
|
+
:int, [:pointer, :string, :int, :pointer]
|
|
29
|
+
) do |_client_ptr, json, _json_len, _opaque|
|
|
30
|
+
if Rdkafka::Config.statistics_callback
|
|
31
|
+
stats = JSON.parse(json)
|
|
32
|
+
|
|
33
|
+
# If user requested statistics callbacks, we can use the statistics data to get the
|
|
34
|
+
# partitions count for each topic when this data is published. That way we do not have
|
|
35
|
+
# to query this information when user is using `partition_key`. This takes around 0.02ms
|
|
36
|
+
# every statistics interval period (most likely every 5 seconds) and saves us from making
|
|
37
|
+
# any queries to the cluster for the partition count.
|
|
38
|
+
#
|
|
39
|
+
# One edge case is if user would set the `statistics.interval.ms` much higher than the
|
|
40
|
+
# default current partition count refresh (30 seconds). This is taken care of as the lack
|
|
41
|
+
# of reporting to the partitions cache will cause cache expire and blocking refresh.
|
|
42
|
+
#
|
|
43
|
+
# If user sets `topic.metadata.refresh.interval.ms` too high this is on the user.
|
|
44
|
+
#
|
|
45
|
+
# Since this cache is shared, having few consumers and/or producers in one process will
|
|
46
|
+
# automatically improve the querying times even with low refresh times.
|
|
47
|
+
(stats["topics"] || EMPTY_HASH).each do |topic_name, details|
|
|
48
|
+
partitions_count = details["partitions"].keys.count { |k| !(k == RD_KAFKA_PARTITION_UA_STR) }
|
|
49
|
+
|
|
50
|
+
next unless partitions_count.positive?
|
|
51
|
+
|
|
52
|
+
Rdkafka::Producer.partitions_count_cache.set(topic_name, partitions_count)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
Rdkafka::Config.statistics_callback.call(stats)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Return 0 so librdkafka frees the json string
|
|
59
|
+
RD_KAFKA_RESP_ERR_NO_ERROR
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
ErrorCallback = FFI::Function.new(
|
|
63
|
+
:void, [:pointer, :int, :string, :pointer]
|
|
64
|
+
) do |client_ptr, err_code, reason, _opaque|
|
|
65
|
+
if Rdkafka::Config.error_callback
|
|
66
|
+
instance_name = client_ptr.null? ? nil : Rdkafka::Bindings.rd_kafka_name(client_ptr)
|
|
67
|
+
error = Rdkafka::RdkafkaError.new(err_code, broker_message: reason, instance_name: instance_name)
|
|
68
|
+
error.set_backtrace(caller)
|
|
69
|
+
Rdkafka::Config.error_callback.call(error)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# The OAuth callback is currently global and contextless. This means that the callback will be
|
|
74
|
+
# called for all instances, and the callback must be able to determine to which instance it is
|
|
75
|
+
# associated. The instance name will be provided in the callback, allowing the callback to
|
|
76
|
+
# reference the correct instance.
|
|
77
|
+
#
|
|
78
|
+
# An example of how to use the instance name in the callback is given below.
|
|
79
|
+
# The `refresh_token` is configured as the `oauthbearer_token_refresh_callback`.
|
|
80
|
+
# `instances` is a map of client names to client instances, maintained by the user.
|
|
81
|
+
#
|
|
82
|
+
# ```
|
|
83
|
+
# def refresh_token(config, client_name)
|
|
84
|
+
# client = instances[client_name]
|
|
85
|
+
# client.oauthbearer_set_token(
|
|
86
|
+
# token: 'new-token-value',
|
|
87
|
+
# lifetime_ms: token-lifetime-ms,
|
|
88
|
+
# principal_name: 'principal-name'
|
|
89
|
+
# )
|
|
90
|
+
# end
|
|
91
|
+
# ```
|
|
92
|
+
OAuthbearerTokenRefreshCallback = FFI::Function.new(
|
|
93
|
+
:void, [:pointer, :string, :pointer]
|
|
94
|
+
) do |client_ptr, config, _opaque|
|
|
95
|
+
if Rdkafka::Config.oauthbearer_token_refresh_callback && !client_ptr.null?
|
|
96
|
+
Rdkafka::Config.oauthbearer_token_refresh_callback.call(config, Rdkafka::Bindings.rd_kafka_name(client_ptr))
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Bindings
|
|
5
|
+
# Configuration
|
|
6
|
+
|
|
7
|
+
enum :kafka_config_response, [
|
|
8
|
+
:config_unknown, -2,
|
|
9
|
+
:config_invalid, -1,
|
|
10
|
+
:config_ok, 0
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
attach_function :rd_kafka_conf_new, [], :pointer
|
|
14
|
+
attach_function :rd_kafka_conf_set, [:pointer, :string, :string, :pointer, :int], :kafka_config_response
|
|
15
|
+
attach_function :rd_kafka_conf_get, [:pointer, :string, :pointer, :pointer], :kafka_config_response
|
|
16
|
+
attach_function :rd_kafka_conf, [:pointer], :pointer
|
|
17
|
+
attach_function :rd_kafka_conf_dump, [:pointer, :pointer], :pointer
|
|
18
|
+
attach_function :rd_kafka_conf_dump_free, [:pointer, :size_t], :void
|
|
19
|
+
attach_function :rd_kafka_conf_destroy, [:pointer], :void
|
|
20
|
+
callback :log_cb, [:pointer, :int, :string, :string], :void
|
|
21
|
+
attach_function :rd_kafka_conf_set_log_cb, [:pointer, :log_cb], :void
|
|
22
|
+
attach_function :rd_kafka_conf_set_opaque, [:pointer, :pointer], :void
|
|
23
|
+
callback :stats_cb, [:pointer, :string, :int, :pointer], :int
|
|
24
|
+
attach_function :rd_kafka_conf_set_stats_cb, [:pointer, :stats_cb], :void
|
|
25
|
+
callback :error_cb, [:pointer, :int, :string, :pointer], :void
|
|
26
|
+
attach_function :rd_kafka_conf_set_error_cb, [:pointer, :error_cb], :void
|
|
27
|
+
attach_function :rd_kafka_rebalance_protocol, [:pointer], :string
|
|
28
|
+
callback :oauthbearer_token_refresh_cb, [:pointer, :string, :pointer], :void
|
|
29
|
+
attach_function :rd_kafka_conf_set_oauthbearer_token_refresh_cb, [:pointer, :oauthbearer_token_refresh_cb], :void
|
|
30
|
+
attach_function :rd_kafka_oauthbearer_set_token, [:pointer, :string, :int64, :pointer, :pointer, :int, :pointer, :int], :int
|
|
31
|
+
attach_function :rd_kafka_oauthbearer_set_token_failure, [:pointer, :string], :int
|
|
32
|
+
# Log queue
|
|
33
|
+
attach_function :rd_kafka_set_log_queue, [:pointer, :pointer], :void
|
|
34
|
+
attach_function :rd_kafka_queue_get_main, [:pointer], :pointer
|
|
35
|
+
attach_function :rd_kafka_queue_get_background, [:pointer], :pointer
|
|
36
|
+
|
|
37
|
+
# Queue IO Event Support - for fiber scheduler integration
|
|
38
|
+
# Enables notifications to a custom FD when queue transitions from empty to non-empty
|
|
39
|
+
# Arguments:
|
|
40
|
+
# - queue (rd_kafka_queue_t*) - the queue to monitor
|
|
41
|
+
# - fd (int) - file descriptor to write to (provide your own pipe/eventfd)
|
|
42
|
+
# - payload (const void*) - data to write to fd
|
|
43
|
+
# - size (size_t) - size of payload
|
|
44
|
+
attach_function :rd_kafka_queue_io_event_enable, [:pointer, :int, :pointer, :size_t], :void
|
|
45
|
+
# Per topic configs
|
|
46
|
+
attach_function :rd_kafka_topic_conf_new, [], :pointer
|
|
47
|
+
attach_function :rd_kafka_topic_conf_destroy, [:pointer], :void
|
|
48
|
+
attach_function :rd_kafka_topic_conf_set, [:pointer, :string, :string, :pointer, :int], :kafka_config_response
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Bindings
|
|
5
|
+
# Consumer
|
|
6
|
+
|
|
7
|
+
attach_function :rd_kafka_subscribe, [:pointer, :pointer], :int, blocking: true
|
|
8
|
+
attach_function :rd_kafka_unsubscribe, [:pointer], :int, blocking: true
|
|
9
|
+
attach_function :rd_kafka_subscription, [:pointer, :pointer], :int, blocking: true
|
|
10
|
+
attach_function :rd_kafka_assign, [:pointer, :pointer], :int, blocking: true
|
|
11
|
+
attach_function :rd_kafka_incremental_assign, [:pointer, :pointer], :int, blocking: true
|
|
12
|
+
attach_function :rd_kafka_incremental_unassign, [:pointer, :pointer], :int, blocking: true
|
|
13
|
+
attach_function :rd_kafka_assignment, [:pointer, :pointer], :int, blocking: true
|
|
14
|
+
attach_function :rd_kafka_assignment_lost, [:pointer], :int, blocking: true
|
|
15
|
+
attach_function :rd_kafka_committed, [:pointer, :pointer, :int], :int, blocking: true
|
|
16
|
+
attach_function :rd_kafka_commit, [:pointer, :pointer, :bool], :int, blocking: true
|
|
17
|
+
attach_function :rd_kafka_poll_set_consumer, [:pointer], :void, blocking: true
|
|
18
|
+
attach_function :rd_kafka_consumer_poll, [:pointer, :int], :pointer, blocking: true
|
|
19
|
+
# Non-blocking consumer poll variant (does not release GVL)
|
|
20
|
+
# More efficient for poll(0) calls in fiber schedulers.
|
|
21
|
+
attach_function :rd_kafka_consumer_poll_nb, :rd_kafka_consumer_poll, [:pointer, :int], :pointer, blocking: false
|
|
22
|
+
attach_function :rd_kafka_consumer_close, [:pointer], :void, blocking: true
|
|
23
|
+
attach_function :rd_kafka_queue_get_consumer, [:pointer], :pointer
|
|
24
|
+
attach_function :rd_kafka_consume_batch_queue, [:pointer, :int, :pointer, :size_t], :ssize_t, blocking: true
|
|
25
|
+
attach_function :rd_kafka_consume_batch_queue_nb, :rd_kafka_consume_batch_queue, [:pointer, :int, :pointer, :size_t], :ssize_t, blocking: false
|
|
26
|
+
attach_function :rd_kafka_offsets_store, [:pointer, :pointer], :int, blocking: true
|
|
27
|
+
attach_function :rd_kafka_pause_partitions, [:pointer, :pointer], :int, blocking: true
|
|
28
|
+
attach_function :rd_kafka_resume_partitions, [:pointer, :pointer], :int, blocking: true
|
|
29
|
+
attach_function :rd_kafka_seek, [:pointer, :int32, :int64, :int], :int, blocking: true
|
|
30
|
+
attach_function :rd_kafka_offsets_for_times, [:pointer, :pointer, :int], :int, blocking: true
|
|
31
|
+
attach_function :rd_kafka_position, [:pointer, :pointer], :int, blocking: true
|
|
32
|
+
# those two are used for eos support
|
|
33
|
+
attach_function :rd_kafka_consumer_group_metadata, [:pointer], :pointer, blocking: true
|
|
34
|
+
attach_function :rd_kafka_consumer_group_metadata_destroy, [:pointer], :void, blocking: true
|
|
35
|
+
|
|
36
|
+
# Headers
|
|
37
|
+
attach_function :rd_kafka_header_get_all, [:pointer, :size_t, :pointer, :pointer, SizePtr], :int
|
|
38
|
+
attach_function :rd_kafka_message_headers, [:pointer, :pointer], :int
|
|
39
|
+
|
|
40
|
+
# Rebalance
|
|
41
|
+
|
|
42
|
+
callback :rebalance_cb_function, [:pointer, :int, :pointer, :pointer], :void
|
|
43
|
+
attach_function :rd_kafka_conf_set_rebalance_cb, [:pointer, :rebalance_cb_function], :void, blocking: true
|
|
44
|
+
|
|
45
|
+
RebalanceCallback = FFI::Function.new(
|
|
46
|
+
:void, [:pointer, :int, :pointer, :pointer]
|
|
47
|
+
) do |client_ptr, code, partitions_ptr, opaque_ptr|
|
|
48
|
+
case code
|
|
49
|
+
when RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS
|
|
50
|
+
if Rdkafka::Bindings.rd_kafka_rebalance_protocol(client_ptr) == "COOPERATIVE"
|
|
51
|
+
Rdkafka::Bindings.rd_kafka_incremental_assign(client_ptr, partitions_ptr)
|
|
52
|
+
else
|
|
53
|
+
Rdkafka::Bindings.rd_kafka_assign(client_ptr, partitions_ptr)
|
|
54
|
+
end
|
|
55
|
+
else # RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS or errors
|
|
56
|
+
if Rdkafka::Bindings.rd_kafka_rebalance_protocol(client_ptr) == "COOPERATIVE"
|
|
57
|
+
Rdkafka::Bindings.rd_kafka_incremental_unassign(client_ptr, partitions_ptr)
|
|
58
|
+
else
|
|
59
|
+
Rdkafka::Bindings.rd_kafka_assign(client_ptr, FFI::Pointer::NULL)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
opaque = Rdkafka::Config.opaques[opaque_ptr.to_i]
|
|
64
|
+
return unless opaque
|
|
65
|
+
|
|
66
|
+
tpl = Rdkafka::Consumer::TopicPartitionList.from_native_tpl(partitions_ptr).freeze
|
|
67
|
+
begin
|
|
68
|
+
case code
|
|
69
|
+
when RD_KAFKA_RESP_ERR__ASSIGN_PARTITIONS
|
|
70
|
+
opaque.call_on_partitions_assigned(tpl)
|
|
71
|
+
when RD_KAFKA_RESP_ERR__REVOKE_PARTITIONS
|
|
72
|
+
opaque.call_on_partitions_revoked(tpl)
|
|
73
|
+
end
|
|
74
|
+
rescue Exception => err
|
|
75
|
+
Rdkafka::Config.logger.error("Unhandled exception: #{err.class} - #{err.message}")
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Watermark offsets
|
|
80
|
+
|
|
81
|
+
attach_function :rd_kafka_query_watermark_offsets, [:pointer, :string, :int, :pointer, :pointer, :int], :int, blocking: true
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Bindings
|
|
5
|
+
attach_function :rd_kafka_err2name, [:int], :string
|
|
6
|
+
attach_function :rd_kafka_err2str, [:int], :string
|
|
7
|
+
attach_function :rd_kafka_error_is_fatal, [:pointer], :int
|
|
8
|
+
attach_function :rd_kafka_error_is_retriable, [:pointer], :int
|
|
9
|
+
attach_function :rd_kafka_error_txn_requires_abort, [:pointer], :int
|
|
10
|
+
attach_function :rd_kafka_error_destroy, [:pointer], :void
|
|
11
|
+
attach_function :rd_kafka_error_code, [:pointer], :int32
|
|
12
|
+
attach_function :rd_kafka_error_string, [:pointer], :pointer
|
|
13
|
+
attach_function :rd_kafka_get_err_descs, [:pointer, :pointer], :void
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Bindings
|
|
5
|
+
# Handle
|
|
6
|
+
|
|
7
|
+
enum :kafka_type, [
|
|
8
|
+
:rd_kafka_producer,
|
|
9
|
+
:rd_kafka_consumer
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
attach_function :rd_kafka_new, [:kafka_type, :pointer, :pointer, :int], :pointer
|
|
13
|
+
|
|
14
|
+
attach_function :rd_kafka_destroy, [:pointer], :void
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rdkafka
|
|
4
|
+
module Bindings
|
|
5
|
+
# Messages, topics and topic partition lists
|
|
6
|
+
|
|
7
|
+
attach_function :rd_kafka_message_destroy, [:pointer], :void
|
|
8
|
+
attach_function :rd_kafka_message_timestamp, [:pointer, :pointer], :int64
|
|
9
|
+
attach_function :rd_kafka_message_latency, [:pointer], :int64
|
|
10
|
+
attach_function :rd_kafka_message_broker_id, [:pointer], :int32
|
|
11
|
+
attach_function :rd_kafka_message_status, [:pointer], :int
|
|
12
|
+
|
|
13
|
+
# Message persistence status (rd_kafka_msg_status_t)
|
|
14
|
+
RD_KAFKA_MSG_STATUS_NOT_PERSISTED = 0
|
|
15
|
+
RD_KAFKA_MSG_STATUS_POSSIBLY_PERSISTED = 1
|
|
16
|
+
RD_KAFKA_MSG_STATUS_PERSISTED = 2
|
|
17
|
+
|
|
18
|
+
attach_function :rd_kafka_topic_new, [:pointer, :string, :pointer], :pointer
|
|
19
|
+
attach_function :rd_kafka_topic_destroy, [:pointer], :pointer
|
|
20
|
+
attach_function :rd_kafka_topic_name, [:pointer], :string
|
|
21
|
+
|
|
22
|
+
attach_function :rd_kafka_topic_partition_list_new, [:int32], :pointer
|
|
23
|
+
attach_function :rd_kafka_topic_partition_list_add, [:pointer, :string, :int32], :pointer
|
|
24
|
+
attach_function :rd_kafka_topic_partition_list_set_offset, [:pointer, :string, :int32, :int64], :void
|
|
25
|
+
attach_function :rd_kafka_topic_partition_list_destroy, [:pointer], :void
|
|
26
|
+
attach_function :rd_kafka_topic_partition_list_copy, [:pointer], :pointer
|
|
27
|
+
end
|
|
28
|
+
end
|