7.x - Implement AdminClient with topic management operations#592
Open
aknEvrnky wants to merge 5 commits intoarnaud-lb:7.xfrom
Open
7.x - Implement AdminClient with topic management operations#592aknEvrnky wants to merge 5 commits intoarnaud-lb:7.xfrom
aknEvrnky wants to merge 5 commits intoarnaud-lb:7.xfrom
Conversation
added 5 commits
February 25, 2026 20:47
…itions Add the foundation for librdkafka Admin API support (issue arnaud-lb#215). New classes in RdKafka\Admin namespace: - AdminClient: wraps rd_kafka_t handle, provides admin operations - AdminOptions: configurable options (timeout, validate_only, broker) - NewTopic: input for createTopics with config and replica assignment - DeleteTopic: input for deleteTopics - NewPartitions: input for createPartitions with replica assignment - TopicResult: per-topic operation result with error and name AdminOptions is created via AdminClient::newAdminOptions() factory because rd_kafka_AdminOptions_new() requires a rd_kafka_t handle. All operations are synchronous: internally creates a queue, calls the librdkafka async operation, polls for the result, and returns it.
Complete the Topic Management category of the Admin API. New methods on AdminClient: - describeTopics(string[] $topics): returns TopicDescription[] with partition info, leader nodes, ISR, replicas, and topic UUID - deleteRecords(TopicPartition[] $partitions): deletes records up to specified offsets, returns resulting offsets New result classes in RdKafka\Admin namespace: - Node: broker node with id, host, port, rack - TopicPartitionInfo: partition details with leader, ISR, replicas - TopicDescription: full topic info with partitions and error status New AdminOptions setter: - setIncludeAuthorizedOperations() for DescribeTopics Node and TopicPartitionInfo are shared types that will be reused by DescribeCluster and DescribeConsumerGroups in future phases.
Cover createTopics, deleteTopics, createPartitions, describeTopics, and deleteRecords with end-to-end tests against a running broker.
Add admin_client source files and test files to package.xml so they are included in PECL builds. Add config.w32 entry for Windows builds. Guard DescribeTopics APIs (Node, TopicDescription, TopicPartitionInfo, setIncludeAuthorizedOperations) with HAS_RD_KAFKA_DESCRIBE_TOPICS for librdkafka < 2.3.0 compatibility.
|
👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
RdKafka\Admin\AdminClientclass that exposes librdkafka's admin API to PHP, covering the 5 most-requested topic management operations:New classes
RdKafka\Admin\AdminClientrd_kafka_thandleRdKafka\Admin\AdminOptionsRdKafka\Admin\NewTopiccreateTopics()RdKafka\Admin\DeleteTopicdeleteTopics()RdKafka\Admin\NewPartitionscreatePartitions()RdKafka\Admin\TopicResultRdKafka\Admin\TopicDescriptiondescribeTopics()RdKafka\Admin\TopicPartitionInfoRdKafka\Admin\NodeDesign decisions
AdminOptionsvia factory method ($admin->newAdminOptions(RD_KAFKA_ADMIN_OP_*)) because the underlying C API requires therd_kafka_thandle.describeTopics()takesstring[]instead of exposing aTopicCollectionwrapper class — keeps the API simple while the collection is built internally.deleteRecords()takesTopicPartition[]— reuses the existingRdKafka\TopicPartitionclass and internal helpers.Tests
admin_client_001.phpt) — object creation and configuration without a brokeradmin_client_create_delete_topics.phptadmin_client_describe_topics.phptadmin_client_create_partitions.phptadmin_client_delete_records.phptRelated issues
Addresses the topic management portion of:
Consumer group operations (#454) and remaining admin APIs can follow as separate PRs.