├── .gitattributes ├── .gitignore ├── LICENSE ├── README.cn.md ├── README.md ├── composer.json └── src ├── Broker.php ├── Client ├── ClientInterface.php ├── SwooleClient.php └── SyncClient.php ├── Config ├── AbstractConfig.php ├── CommonConfig.php └── SslConfig.php ├── Consumer ├── Assignor │ ├── AbstractPartitionAssignor.php │ ├── PartitionAssignorInterface.php │ ├── PartitionMovements.php │ ├── RangeAssignor.php │ ├── RoundRobinAssignor.php │ ├── StickyAssignor.php │ └── Struct │ │ └── TopicAndPartition.php ├── ConsumeMessage.php ├── Consumer.php ├── ConsumerConfig.php ├── OffsetManager.php └── Struct │ ├── ConsumerGenerationPair.php │ ├── ConsumerGroupMemberMetadata.php │ ├── ConsumerPair.php │ ├── StickyAssignorUserData.php │ └── TopicPartition.php ├── Exception ├── CRC32Exception.php ├── ConnectionException.php ├── KafkaErrorException.php ├── NoAliveBrokerException.php ├── SocketException.php ├── UnknownException.php ├── UnsupportedApiKeyException.php ├── UnsupportedApiVersionException.php └── UnsupportedCompressionException.php ├── Generator ├── AbstractGenerator.php ├── MessageGenerator.php ├── StructGenerator.php └── SubStructGenerator.php ├── Group ├── CoordinatorType.php ├── GroupManager.php ├── ProtocolType.php └── Struct │ ├── ConsumerGroupMemberAssignment.php │ └── ConsumerGroupTopic.php ├── Producer ├── Partitioner │ ├── DefaultPartitioner.php │ └── PartitionerInterface.php ├── ProduceMessage.php ├── Producer.php └── ProducerConfig.php ├── Protocol ├── AbstractApiKeys.php ├── AbstractProtocol.php ├── AbstractRequest.php ├── AbstractRequestHeader.php ├── AbstractResponse.php ├── AbstractResponseHeader.php ├── AbstractStruct.php ├── AddOffsetsToTxn │ ├── AddOffsetsToTxnRequest.php │ └── AddOffsetsToTxnResponse.php ├── AddPartitionsToTxn │ ├── AddPartitionsToTxnPartitionResult.php │ ├── AddPartitionsToTxnRequest.php │ ├── AddPartitionsToTxnResponse.php │ ├── AddPartitionsToTxnTopic.php │ └── AddPartitionsToTxnTopicResult.php ├── AlterClientQuotas │ ├── AlterClientQuotasRequest.php │ ├── AlterClientQuotasResponse.php │ ├── EntityData.php │ ├── EntryData.php │ └── OpData.php ├── AlterConfigs │ ├── AlterConfigsRequest.php │ ├── AlterConfigsResource.php │ ├── AlterConfigsResourceResponse.php │ ├── AlterConfigsResponse.php │ └── AlterableConfig.php ├── AlterPartitionReassignments │ ├── AlterPartitionReassignmentsRequest.php │ ├── AlterPartitionReassignmentsResponse.php │ ├── ReassignablePartition.php │ ├── ReassignablePartitionResponse.php │ ├── ReassignableTopic.php │ └── ReassignableTopicResponse.php ├── AlterReplicaLogDirs │ ├── AlterReplicaLogDir.php │ ├── AlterReplicaLogDirPartitionResult.php │ ├── AlterReplicaLogDirTopic.php │ ├── AlterReplicaLogDirTopicResult.php │ ├── AlterReplicaLogDirsRequest.php │ └── AlterReplicaLogDirsResponse.php ├── ApiKeys.php ├── ApiVersion.php ├── ApiVersions │ ├── ApiVersionsRequest.php │ ├── ApiVersionsResponse.php │ └── ApiVersionsResponseKey.php ├── ControlledShutdown │ ├── ControlledShutdownRequest.php │ ├── ControlledShutdownResponse.php │ └── RemainingPartition.php ├── CreateAcls │ ├── AclCreation.php │ ├── AclCreationResult.php │ ├── CreateAclsRequest.php │ └── CreateAclsResponse.php ├── CreateDelegationToken │ ├── CreatableRenewers.php │ ├── CreateDelegationTokenRequest.php │ └── CreateDelegationTokenResponse.php ├── CreatePartitions │ ├── CreatePartitionsAssignment.php │ ├── CreatePartitionsRequest.php │ ├── CreatePartitionsResponse.php │ ├── CreatePartitionsTopic.php │ └── CreatePartitionsTopicResult.php ├── CreateTopics │ ├── CreatableReplicaAssignment.php │ ├── CreatableTopic.php │ ├── CreatableTopicConfigs.php │ ├── CreatableTopicResult.php │ ├── CreateTopicsRequest.php │ ├── CreateTopicsResponse.php │ └── CreateableTopicConfig.php ├── DeleteAcls │ ├── DeleteAclsFilter.php │ ├── DeleteAclsFilterResult.php │ ├── DeleteAclsMatchingAcl.php │ ├── DeleteAclsRequest.php │ └── DeleteAclsResponse.php ├── DeleteGroups │ ├── DeletableGroupResult.php │ ├── DeleteGroupsRequest.php │ └── DeleteGroupsResponse.php ├── DeleteRecords │ ├── DeleteRecordsPartition.php │ ├── DeleteRecordsPartitionResult.php │ ├── DeleteRecordsRequest.php │ ├── DeleteRecordsResponse.php │ ├── DeleteRecordsTopic.php │ └── DeleteRecordsTopicResult.php ├── DeleteTopics │ ├── DeletableTopicResult.php │ ├── DeleteTopicsRequest.php │ └── DeleteTopicsResponse.php ├── DescribeAcls │ ├── AclDescription.php │ ├── DescribeAclsRequest.php │ ├── DescribeAclsResource.php │ └── DescribeAclsResponse.php ├── DescribeClientQuotas │ ├── ComponentData.php │ ├── DescribeClientQuotasRequest.php │ ├── DescribeClientQuotasResponse.php │ ├── EntityData.php │ ├── EntryData.php │ └── ValueData.php ├── DescribeConfigs │ ├── DescribeConfigsRequest.php │ ├── DescribeConfigsResource.php │ ├── DescribeConfigsResourceResult.php │ ├── DescribeConfigsResponse.php │ ├── DescribeConfigsResult.php │ └── DescribeConfigsSynonym.php ├── DescribeDelegationToken │ ├── DescribeDelegationTokenOwner.php │ ├── DescribeDelegationTokenRequest.php │ ├── DescribeDelegationTokenResponse.php │ ├── DescribedDelegationToken.php │ └── DescribedDelegationTokenRenewer.php ├── DescribeGroups │ ├── DescribeGroupsRequest.php │ ├── DescribeGroupsResponse.php │ ├── DescribedGroup.php │ └── DescribedGroupMember.php ├── DescribeLogDirs │ ├── DescribableLogDirTopic.php │ ├── DescribeLogDirsPartition.php │ ├── DescribeLogDirsRequest.php │ ├── DescribeLogDirsResponse.php │ ├── DescribeLogDirsResult.php │ └── DescribeLogDirsTopic.php ├── ElectLeaders │ ├── ElectLeadersRequest.php │ ├── ElectLeadersResponse.php │ ├── PartitionResult.php │ ├── ReplicaElectionResult.php │ └── TopicPartitions.php ├── EndTxn │ ├── EndTxnRequest.php │ └── EndTxnResponse.php ├── ErrorCode.php ├── ExpireDelegationToken │ ├── ExpireDelegationTokenRequest.php │ └── ExpireDelegationTokenResponse.php ├── Fetch │ ├── AbortedTransaction.php │ ├── FetchPartition.php │ ├── FetchRequest.php │ ├── FetchResponse.php │ ├── FetchablePartitionResponse.php │ ├── FetchableTopic.php │ ├── FetchableTopicResponse.php │ └── ForgottenTopic.php ├── FindCoordinator │ ├── FindCoordinatorRequest.php │ └── FindCoordinatorResponse.php ├── Heartbeat │ ├── HeartbeatRequest.php │ └── HeartbeatResponse.php ├── IncrementalAlterConfigs │ ├── AlterConfigsResource.php │ ├── AlterConfigsResourceResponse.php │ ├── AlterableConfig.php │ ├── IncrementalAlterConfigsRequest.php │ └── IncrementalAlterConfigsResponse.php ├── InitProducerId │ ├── InitProducerIdRequest.php │ └── InitProducerIdResponse.php ├── JoinGroup │ ├── JoinGroupRequest.php │ ├── JoinGroupRequestProtocol.php │ ├── JoinGroupResponse.php │ └── JoinGroupResponseMember.php ├── KafkaRequest.php ├── LeaderAndIsr │ ├── LeaderAndIsrLiveLeader.php │ ├── LeaderAndIsrPartitionError.php │ ├── LeaderAndIsrPartitionState.php │ ├── LeaderAndIsrRequest.php │ ├── LeaderAndIsrResponse.php │ └── LeaderAndIsrTopicState.php ├── LeaveGroup │ ├── LeaveGroupRequest.php │ ├── LeaveGroupResponse.php │ ├── MemberIdentity.php │ └── MemberResponse.php ├── ListGroups │ ├── ListGroupsRequest.php │ ├── ListGroupsResponse.php │ └── ListedGroup.php ├── ListOffset │ ├── ListOffsetPartition.php │ ├── ListOffsetPartitionResponse.php │ ├── ListOffsetRequest.php │ ├── ListOffsetResponse.php │ ├── ListOffsetTopic.php │ └── ListOffsetTopicResponse.php ├── ListPartitionReassignments │ ├── ListPartitionReassignmentsRequest.php │ ├── ListPartitionReassignmentsResponse.php │ ├── ListPartitionReassignmentsTopics.php │ ├── OngoingPartitionReassignment.php │ └── OngoingTopicReassignment.php ├── Metadata │ ├── MetadataRequest.php │ ├── MetadataRequestTopic.php │ ├── MetadataResponse.php │ ├── MetadataResponseBroker.php │ ├── MetadataResponsePartition.php │ └── MetadataResponseTopic.php ├── OffsetCommit │ ├── OffsetCommitRequest.php │ ├── OffsetCommitRequestPartition.php │ ├── OffsetCommitRequestTopic.php │ ├── OffsetCommitResponse.php │ ├── OffsetCommitResponsePartition.php │ └── OffsetCommitResponseTopic.php ├── OffsetDelete │ ├── OffsetDeleteRequest.php │ ├── OffsetDeleteRequestPartition.php │ ├── OffsetDeleteRequestTopic.php │ ├── OffsetDeleteResponse.php │ ├── OffsetDeleteResponsePartition.php │ └── OffsetDeleteResponseTopic.php ├── OffsetFetch │ ├── OffsetFetchRequest.php │ ├── OffsetFetchRequestTopic.php │ ├── OffsetFetchResponse.php │ ├── OffsetFetchResponsePartition.php │ └── OffsetFetchResponseTopic.php ├── OffsetForLeaderEpoch │ ├── OffsetForLeaderEpochRequest.php │ ├── OffsetForLeaderEpochResponse.php │ ├── OffsetForLeaderPartition.php │ ├── OffsetForLeaderPartitionResult.php │ ├── OffsetForLeaderTopic.php │ └── OffsetForLeaderTopicResult.php ├── Produce │ ├── BatchIndexAndErrorMessage.php │ ├── PartitionProduceData.php │ ├── PartitionProduceResponse.php │ ├── ProduceRequest.php │ ├── ProduceResponse.php │ ├── TopicProduceData.php │ └── TopicProduceResponse.php ├── ProtocolField.php ├── ProtocolUtil.php ├── RecordBatch │ ├── Attributes.php │ ├── Enum │ │ ├── Compression.php │ │ └── TimestampType.php │ ├── Record.php │ ├── RecordBatch.php │ └── RecordHeader.php ├── RenewDelegationToken │ ├── RenewDelegationTokenRequest.php │ └── RenewDelegationTokenResponse.php ├── RequestHeader │ └── RequestHeader.php ├── ResponseHeader │ └── ResponseHeader.php ├── SaslAuthenticate │ ├── SaslAuthenticateRequest.php │ └── SaslAuthenticateResponse.php ├── SaslHandshake │ ├── SaslHandshakeRequest.php │ └── SaslHandshakeResponse.php ├── StopReplica │ ├── StopReplicaPartitionError.php │ ├── StopReplicaPartitionState.php │ ├── StopReplicaPartitionV0.php │ ├── StopReplicaRequest.php │ ├── StopReplicaResponse.php │ ├── StopReplicaTopicState.php │ └── StopReplicaTopicV1.php ├── SyncGroup │ ├── SyncGroupRequest.php │ ├── SyncGroupRequestAssignment.php │ └── SyncGroupResponse.php ├── TxnOffsetCommit │ ├── TxnOffsetCommitRequest.php │ ├── TxnOffsetCommitRequestPartition.php │ ├── TxnOffsetCommitRequestTopic.php │ ├── TxnOffsetCommitResponse.php │ ├── TxnOffsetCommitResponsePartition.php │ └── TxnOffsetCommitResponseTopic.php ├── Type │ ├── AbstractType.php │ ├── ArrayInt32.php │ ├── Boolean.php │ ├── CompactArray.php │ ├── CompactNullableString.php │ ├── CompactString.php │ ├── Float64.php │ ├── Int16.php │ ├── Int32.php │ ├── Int64.php │ ├── Int8.php │ ├── NullableString.php │ ├── NullableString32.php │ ├── String16.php │ ├── String32.php │ ├── TypeRelation.php │ ├── UInt32.php │ ├── UVarInt.php │ ├── VarInt.php │ └── VarIntCompactArray.php ├── UpdateMetadata │ ├── UpdateMetadataBroker.php │ ├── UpdateMetadataEndpoint.php │ ├── UpdateMetadataPartitionState.php │ ├── UpdateMetadataRequest.php │ ├── UpdateMetadataResponse.php │ └── UpdateMetadataTopicState.php └── WriteTxnMarkers │ ├── WritableTxnMarker.php │ ├── WritableTxnMarkerPartitionResult.php │ ├── WritableTxnMarkerResult.php │ ├── WritableTxnMarkerTopic.php │ ├── WritableTxnMarkerTopicResult.php │ ├── WriteTxnMarkersRequest.php │ └── WriteTxnMarkersResponse.php ├── Sasl ├── PlainSasl.php └── SaslInterface.php ├── Socket ├── SocketInterface.php ├── StreamSocket.php └── SwooleSocket.php ├── Timer ├── NoopTimer.php ├── SwooleTimer.php └── TimerInterface.php └── Util ├── ArrayUtil.php ├── KafkaUtil.php ├── LZ4.php └── ObjectKeyArray.php /.gitattributes: -------------------------------------------------------------------------------- 1 | # Exclude non-essential files from dist 2 | /.github export-ignore 3 | /bin export-ignore 4 | /doc export-ignore 5 | /examples export-ignore 6 | /res export-ignore 7 | /tests export-ignore 8 | .php_cs.dist export-ignore 9 | phpstan.neon export-ignore 10 | phpunit.xml.dist export-ignore 11 | swoole-phpunit export-ignore -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | .vscode/ 3 | .idea/ 4 | .buildpath 5 | .settings/ 6 | .project 7 | .DS_Store 8 | *.lock 9 | *.log 10 | /coverage.txt 11 | /.php_cs.cache 12 | *.cache 13 | .bashrc -------------------------------------------------------------------------------- /README.cn.md: -------------------------------------------------------------------------------- 1 | # longlang/phpkafka 2 | 3 | [![Latest Version](https://poser.pugx.org/longlang/phpkafka/v/stable)](https://packagist.org/packages/longlang/phpkafka) 4 | [![Php Version](https://img.shields.io/badge/php-%3E=7.1-brightgreen.svg)](https://secure.php.net/) 5 | [![License](https://img.shields.io/github/license/longyan/phpkafka.svg)](https://github.com/longyan/phpkafka/blob/master/LICENSE) 6 | 7 | ## 简介 8 | 9 | [English](README.md) | 简体中文 10 | 11 | PHP Kafka 客户端,支持 PHP-FPM、Swoole 环境使用。 12 | 13 | 通讯协议的结构基于 Java 版本中的 JSON 文件生成,这可能是有史以来支持消息类型最多的 PHP Kafka 客户端,支持全部 50 个 API。 14 | 15 | > 目前已实现消息的生成及消费,本组件仍处于开发及测试阶段。 16 | 17 | ## 功能特性 18 | 19 | - [x] 支持全部 50 个 API 20 | - [x] 消息压缩支持 (gzip、snappy、lz4、zstd) 21 | - [x] PHP-FPM、Swoole 智能环境识别兼容 22 | - [x] 生产者类 23 | - [x] 消费者类 24 | - [x] SASL 鉴权 25 | - [x] SSL 加密通信 26 | - [ ] 更多功能的封装及测试用例编写 27 | 28 | ## 环境要求 29 | 30 | - PHP >= 7.1 31 | - Kafka >= 1.0.0 32 | - Swoole >= 4.5 (可选) 33 | 34 | ## 安装 35 | 36 | `composer require longlang/phpkafka` 37 | 38 | ## 文档及示例 39 | 40 | - [生产者](doc/producer.md) 41 | 42 | - [消费者](doc/consumer.md) 43 | 44 | 示例代码请参考 `examples` 目录 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # longlang/phpkafka 2 | 3 | [![Latest Version](https://poser.pugx.org/longlang/phpkafka/v/stable)](https://packagist.org/packages/longlang/phpkafka) 4 | [![Php Version](https://img.shields.io/badge/php-%3E=7.1-brightgreen.svg)](https://secure.php.net/) 5 | [![License](https://img.shields.io/github/license/longyan/phpkafka.svg)](https://github.com/longyan/phpkafka/blob/master/LICENSE) 6 | 7 | ## Introduction 8 | 9 | English | [简体中文](README.cn.md) 10 | 11 | PHP Kafka client is used in PHP-FPM and Swoole. 12 | 13 | The communication protocol is based on the JSON file in Java. PHP Kafka client supports 50 APIs, which might be one that supports the most message types ever. 14 | 15 | > The produce and the consume of messages are implemented. The component is in developing and testing. 16 | 17 | ## Features 18 | 19 | - [x] Support all 50 APIs 20 | - [x] Message compression 21 | - [x] PHP-FPM and Swoole compatible 22 | - [x] Producer 23 | - [x] Consumer 24 | - [x] SASL 25 | - [x] SSL 26 | - [ ] More features and test cases 27 | 28 | ## Environment 29 | 30 | - PHP >= 7.1 31 | - Kafka >= 1.0.0 32 | - Swoole >= 4.5 (optional) 33 | 34 | ## Installation 35 | 36 | `composer require longlang/phpkafka` 37 | 38 | ## Documentation and Examples 39 | 40 | - [Producer](doc/producer.en.md) 41 | 42 | - [Consumer](doc/consumer.en.md) 43 | 44 | Refer to `examples` for code examples. 45 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "longlang/phpkafka", 3 | "description": "A kafka client. Support php-fpm and Swoole.", 4 | "license": "Apache-2.0", 5 | "require": { 6 | "php": ">=7.1", 7 | "google/crc32": "^0.1.0", 8 | "exussum12/xxhash": "^1.0.0", 9 | "chdemko/sorted-collections": "^1.0", 10 | "symfony/polyfill-php81": "^1.23" 11 | }, 12 | "require-dev": { 13 | "phpunit/phpunit": "^7.5|^8.0|^9.0", 14 | "colinodell/json5": "^2.1", 15 | "swoole/ide-helper": "^4.5", 16 | "friendsofphp/php-cs-fixer": "^2.18", 17 | "phpstan/phpstan": "^0.12.81" 18 | }, 19 | "autoload": { 20 | "psr-4": { 21 | "longlang\\phpkafka\\": "src" 22 | } 23 | }, 24 | "autoload-dev": { 25 | "psr-4": { 26 | "longlang\\phpkafka\\Test\\": "tests" 27 | } 28 | }, 29 | "scripts": { 30 | "test": "./vendor/bin/phpunit", 31 | "swoole-test": "export KAFKA_CLIENT_CLASS=\"\\longlang\\phpkafka\\Client\\SwooleClient\" && ./swoole-phpunit", 32 | "test-coverage": "php -dzend_extension=xdebug ./vendor/bin/phpunit" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Client/ClientInterface.php: -------------------------------------------------------------------------------- 1 | $v) { 12 | $methodName = 'set' . ucfirst($k); 13 | if (method_exists($this, $methodName)) { 14 | $this->$methodName($v); 15 | } else { 16 | $this->$k = $v; 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Consumer/Assignor/AbstractPartitionAssignor.php: -------------------------------------------------------------------------------- 1 | getName() === $topic) { 26 | $partitions = []; 27 | foreach ($metadata->getPartitions() as $partition) { 28 | $partitions[] = $partition->getPartitionIndex(); 29 | } 30 | 31 | return $partitions; 32 | } 33 | } 34 | 35 | return []; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Consumer/Assignor/PartitionAssignorInterface.php: -------------------------------------------------------------------------------- 1 | topic = $topic; 22 | $this->partition = $partition; 23 | } 24 | 25 | public function getTopic(): string 26 | { 27 | return $this->topic; 28 | } 29 | 30 | public function setTopic(string $topic): self 31 | { 32 | $this->topic = $topic; 33 | 34 | return $this; 35 | } 36 | 37 | public function getPartition(): int 38 | { 39 | return $this->partition; 40 | } 41 | 42 | public function setPartition(int $partition): self 43 | { 44 | $this->partition = $partition; 45 | 46 | return $this; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Consumer/Struct/ConsumerGenerationPair.php: -------------------------------------------------------------------------------- 1 | consumer = $consumer; 22 | $this->generation = $generation; 23 | } 24 | 25 | public function getConsumer(): string 26 | { 27 | return $this->consumer; 28 | } 29 | 30 | public function getGeneration(): int 31 | { 32 | return $this->generation; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Consumer/Struct/ConsumerPair.php: -------------------------------------------------------------------------------- 1 | srcMemberId = $srcMemberId; 22 | $this->dstMemberId = $dstMemberId; 23 | } 24 | 25 | public function __toString() 26 | { 27 | return $this->srcMemberId . '->' . $this->dstMemberId; 28 | } 29 | 30 | public function getSrcMemberId(): string 31 | { 32 | return $this->srcMemberId; 33 | } 34 | 35 | public function getDstMemberId(): string 36 | { 37 | return $this->dstMemberId; 38 | } 39 | 40 | public function in(array $pairs): bool 41 | { 42 | $thisString = (string) $this; 43 | foreach ($pairs as $pair) { 44 | if ((string) $pair === $thisString) { 45 | return true; 46 | } 47 | } 48 | 49 | return false; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Consumer/Struct/StickyAssignorUserData.php: -------------------------------------------------------------------------------- 1 | partitions; 50 | } 51 | 52 | /** 53 | * @param TopicPartition[] $partitions 54 | */ 55 | public function setPartitions(array $partitions): self 56 | { 57 | $this->partitions = $partitions; 58 | 59 | return $this; 60 | } 61 | 62 | public function getGeneration(): ?int 63 | { 64 | return $this->generation; 65 | } 66 | 67 | public function setGeneration(?int $generation): self 68 | { 69 | $this->generation = $generation; 70 | 71 | return $this; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Consumer/Struct/TopicPartition.php: -------------------------------------------------------------------------------- 1 | topic = $topic; 33 | $this->partition = $partition; 34 | } 35 | 36 | public function getMaxSupportedVersion(): int 37 | { 38 | return 1; 39 | } 40 | 41 | public function getFlexibleVersions(): array 42 | { 43 | return []; 44 | } 45 | 46 | public function getTopic(): string 47 | { 48 | return $this->topic; 49 | } 50 | 51 | public function setTopic(string $topic): self 52 | { 53 | $this->topic = $topic; 54 | 55 | return $this; 56 | } 57 | 58 | public function getPartition(): int 59 | { 60 | return $this->partition; 61 | } 62 | 63 | public function setPartition(int $partition): self 64 | { 65 | $this->partition = $partition; 66 | 67 | return $this; 68 | } 69 | 70 | public function __toString() 71 | { 72 | return $this->topic . '-' . $this->partition; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Exception/CRC32Exception.php: -------------------------------------------------------------------------------- 1 | topicName; 47 | } 48 | 49 | public function setTopicName(string $topicName): self 50 | { 51 | $this->topicName = $topicName; 52 | 53 | return $this; 54 | } 55 | 56 | public function getPartitions(): array 57 | { 58 | return $this->partitions; 59 | } 60 | 61 | public function setPartitions(array $partitions): self 62 | { 63 | $this->partitions = $partitions; 64 | 65 | return $this; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Producer/Partitioner/PartitionerInterface.php: -------------------------------------------------------------------------------- 1 | topic = $topic; 42 | $this->value = $value; 43 | $this->key = $key; 44 | $this->headers = $headers; 45 | $this->partitionIndex = $partitionIndex; 46 | } 47 | 48 | public function getTopic(): string 49 | { 50 | return $this->topic; 51 | } 52 | 53 | public function getValue(): ?string 54 | { 55 | return $this->value; 56 | } 57 | 58 | public function getKey(): ?string 59 | { 60 | return $this->key; 61 | } 62 | 63 | /** 64 | * @return RecordHeader[]|array 65 | */ 66 | public function getHeaders(): array 67 | { 68 | return $this->headers; 69 | } 70 | 71 | public function getPartitionIndex(): ?int 72 | { 73 | return $this->partitionIndex; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/Protocol/AbstractProtocol.php: -------------------------------------------------------------------------------- 1 | getRequestApiKey()] ?? 'Unknown'; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Protocol/AbstractRequestHeader.php: -------------------------------------------------------------------------------- 1 | throttleTimeMs; 51 | } 52 | 53 | public function setThrottleTimeMs(int $throttleTimeMs): self 54 | { 55 | $this->throttleTimeMs = $throttleTimeMs; 56 | 57 | return $this; 58 | } 59 | 60 | public function getErrorCode(): int 61 | { 62 | return $this->errorCode; 63 | } 64 | 65 | public function setErrorCode(int $errorCode): self 66 | { 67 | $this->errorCode = $errorCode; 68 | 69 | return $this; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Protocol/AddPartitionsToTxn/AddPartitionsToTxnPartitionResult.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 46 | } 47 | 48 | public function setPartitionIndex(int $partitionIndex): self 49 | { 50 | $this->partitionIndex = $partitionIndex; 51 | 52 | return $this; 53 | } 54 | 55 | public function getErrorCode(): int 56 | { 57 | return $this->errorCode; 58 | } 59 | 60 | public function setErrorCode(int $errorCode): self 61 | { 62 | $this->errorCode = $errorCode; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/AddPartitionsToTxn/AddPartitionsToTxnTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param int[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/AddPartitionsToTxn/AddPartitionsToTxnTopicResult.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return AddPartitionsToTxnPartitionResult[] 57 | */ 58 | public function getResults(): array 59 | { 60 | return $this->results; 61 | } 62 | 63 | /** 64 | * @param AddPartitionsToTxnPartitionResult[] $results 65 | */ 66 | public function setResults(array $results): self 67 | { 68 | $this->results = $results; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/AlterClientQuotas/EntityData.php: -------------------------------------------------------------------------------- 1 | entityType; 46 | } 47 | 48 | public function setEntityType(string $entityType): self 49 | { 50 | $this->entityType = $entityType; 51 | 52 | return $this; 53 | } 54 | 55 | public function getEntityName(): ?string 56 | { 57 | return $this->entityName; 58 | } 59 | 60 | public function setEntityName(?string $entityName): self 61 | { 62 | $this->entityName = $entityName; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/AlterConfigs/AlterableConfig.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | public function getValue(): ?string 56 | { 57 | return $this->value; 58 | } 59 | 60 | public function setValue(?string $value): self 61 | { 62 | $this->value = $value; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/AlterPartitionReassignments/ReassignablePartition.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 46 | } 47 | 48 | public function setPartitionIndex(int $partitionIndex): self 49 | { 50 | $this->partitionIndex = $partitionIndex; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[]|null 57 | */ 58 | public function getReplicas(): ?array 59 | { 60 | return $this->replicas; 61 | } 62 | 63 | /** 64 | * @param int[]|null $replicas 65 | */ 66 | public function setReplicas(?array $replicas): self 67 | { 68 | $this->replicas = $replicas; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/AlterPartitionReassignments/ReassignableTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return ReassignablePartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param ReassignablePartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/AlterPartitionReassignments/ReassignableTopicResponse.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return ReassignablePartitionResponse[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param ReassignablePartitionResponse[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/AlterReplicaLogDirs/AlterReplicaLogDir.php: -------------------------------------------------------------------------------- 1 | path; 46 | } 47 | 48 | public function setPath(string $path): self 49 | { 50 | $this->path = $path; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return AlterReplicaLogDirTopic[] 57 | */ 58 | public function getTopics(): array 59 | { 60 | return $this->topics; 61 | } 62 | 63 | /** 64 | * @param AlterReplicaLogDirTopic[] $topics 65 | */ 66 | public function setTopics(array $topics): self 67 | { 68 | $this->topics = $topics; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/AlterReplicaLogDirs/AlterReplicaLogDirPartitionResult.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 46 | } 47 | 48 | public function setPartitionIndex(int $partitionIndex): self 49 | { 50 | $this->partitionIndex = $partitionIndex; 51 | 52 | return $this; 53 | } 54 | 55 | public function getErrorCode(): int 56 | { 57 | return $this->errorCode; 58 | } 59 | 60 | public function setErrorCode(int $errorCode): self 61 | { 62 | $this->errorCode = $errorCode; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/AlterReplicaLogDirs/AlterReplicaLogDirTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param int[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/AlterReplicaLogDirs/AlterReplicaLogDirTopicResult.php: -------------------------------------------------------------------------------- 1 | topicName; 46 | } 47 | 48 | public function setTopicName(string $topicName): self 49 | { 50 | $this->topicName = $topicName; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return AlterReplicaLogDirPartitionResult[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param AlterReplicaLogDirPartitionResult[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/AlterReplicaLogDirs/AlterReplicaLogDirsRequest.php: -------------------------------------------------------------------------------- 1 | dirs; 51 | } 52 | 53 | /** 54 | * @param AlterReplicaLogDir[] $dirs 55 | */ 56 | public function setDirs(array $dirs): self 57 | { 58 | $this->dirs = $dirs; 59 | 60 | return $this; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Protocol/ApiKeys.php: -------------------------------------------------------------------------------- 1 | unpack($data, $size, $apiVersion); 20 | } 21 | 22 | return $instance; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Protocol/ControlledShutdown/ControlledShutdownRequest.php: -------------------------------------------------------------------------------- 1 | brokerId; 56 | } 57 | 58 | public function setBrokerId(int $brokerId): self 59 | { 60 | $this->brokerId = $brokerId; 61 | 62 | return $this; 63 | } 64 | 65 | public function getBrokerEpoch(): int 66 | { 67 | return $this->brokerEpoch; 68 | } 69 | 70 | public function setBrokerEpoch(int $brokerEpoch): self 71 | { 72 | $this->brokerEpoch = $brokerEpoch; 73 | 74 | return $this; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Protocol/ControlledShutdown/RemainingPartition.php: -------------------------------------------------------------------------------- 1 | topicName; 46 | } 47 | 48 | public function setTopicName(string $topicName): self 49 | { 50 | $this->topicName = $topicName; 51 | 52 | return $this; 53 | } 54 | 55 | public function getPartitionIndex(): int 56 | { 57 | return $this->partitionIndex; 58 | } 59 | 60 | public function setPartitionIndex(int $partitionIndex): self 61 | { 62 | $this->partitionIndex = $partitionIndex; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/CreateAcls/AclCreationResult.php: -------------------------------------------------------------------------------- 1 | errorCode; 46 | } 47 | 48 | public function setErrorCode(int $errorCode): self 49 | { 50 | $this->errorCode = $errorCode; 51 | 52 | return $this; 53 | } 54 | 55 | public function getErrorMessage(): ?string 56 | { 57 | return $this->errorMessage; 58 | } 59 | 60 | public function setErrorMessage(?string $errorMessage): self 61 | { 62 | $this->errorMessage = $errorMessage; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/CreateAcls/CreateAclsRequest.php: -------------------------------------------------------------------------------- 1 | creations; 51 | } 52 | 53 | /** 54 | * @param AclCreation[] $creations 55 | */ 56 | public function setCreations(array $creations): self 57 | { 58 | $this->creations = $creations; 59 | 60 | return $this; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Protocol/CreateDelegationToken/CreatableRenewers.php: -------------------------------------------------------------------------------- 1 | principalType; 46 | } 47 | 48 | public function setPrincipalType(string $principalType): self 49 | { 50 | $this->principalType = $principalType; 51 | 52 | return $this; 53 | } 54 | 55 | public function getPrincipalName(): string 56 | { 57 | return $this->principalName; 58 | } 59 | 60 | public function setPrincipalName(string $principalName): self 61 | { 62 | $this->principalName = $principalName; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/CreatePartitions/CreatePartitionsAssignment.php: -------------------------------------------------------------------------------- 1 | brokerIds; 41 | } 42 | 43 | /** 44 | * @param int[] $brokerIds 45 | */ 46 | public function setBrokerIds(array $brokerIds): self 47 | { 48 | $this->brokerIds = $brokerIds; 49 | 50 | return $this; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Protocol/CreateTopics/CreatableReplicaAssignment.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 46 | } 47 | 48 | public function setPartitionIndex(int $partitionIndex): self 49 | { 50 | $this->partitionIndex = $partitionIndex; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[] 57 | */ 58 | public function getBrokerIds(): array 59 | { 60 | return $this->brokerIds; 61 | } 62 | 63 | /** 64 | * @param int[] $brokerIds 65 | */ 66 | public function setBrokerIds(array $brokerIds): self 67 | { 68 | $this->brokerIds = $brokerIds; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/CreateTopics/CreateableTopicConfig.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | public function getValue(): ?string 56 | { 57 | return $this->value; 58 | } 59 | 60 | public function setValue(?string $value): self 61 | { 62 | $this->value = $value; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/DeleteAcls/DeleteAclsRequest.php: -------------------------------------------------------------------------------- 1 | filters; 51 | } 52 | 53 | /** 54 | * @param DeleteAclsFilter[] $filters 55 | */ 56 | public function setFilters(array $filters): self 57 | { 58 | $this->filters = $filters; 59 | 60 | return $this; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Protocol/DeleteGroups/DeletableGroupResult.php: -------------------------------------------------------------------------------- 1 | groupId; 46 | } 47 | 48 | public function setGroupId(string $groupId): self 49 | { 50 | $this->groupId = $groupId; 51 | 52 | return $this; 53 | } 54 | 55 | public function getErrorCode(): int 56 | { 57 | return $this->errorCode; 58 | } 59 | 60 | public function setErrorCode(int $errorCode): self 61 | { 62 | $this->errorCode = $errorCode; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/DeleteGroups/DeleteGroupsRequest.php: -------------------------------------------------------------------------------- 1 | groupsNames; 51 | } 52 | 53 | /** 54 | * @param string[] $groupsNames 55 | */ 56 | public function setGroupsNames(array $groupsNames): self 57 | { 58 | $this->groupsNames = $groupsNames; 59 | 60 | return $this; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Protocol/DeleteRecords/DeleteRecordsPartition.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 46 | } 47 | 48 | public function setPartitionIndex(int $partitionIndex): self 49 | { 50 | $this->partitionIndex = $partitionIndex; 51 | 52 | return $this; 53 | } 54 | 55 | public function getOffset(): int 56 | { 57 | return $this->offset; 58 | } 59 | 60 | public function setOffset(int $offset): self 61 | { 62 | $this->offset = $offset; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/DeleteRecords/DeleteRecordsTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return DeleteRecordsPartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param DeleteRecordsPartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/DeleteRecords/DeleteRecordsTopicResult.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return DeleteRecordsPartitionResult[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param DeleteRecordsPartitionResult[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/DeleteTopics/DeletableTopicResult.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | public function getErrorCode(): int 56 | { 57 | return $this->errorCode; 58 | } 59 | 60 | public function setErrorCode(int $errorCode): self 61 | { 62 | $this->errorCode = $errorCode; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/DescribeClientQuotas/EntityData.php: -------------------------------------------------------------------------------- 1 | entityType; 46 | } 47 | 48 | public function setEntityType(string $entityType): self 49 | { 50 | $this->entityType = $entityType; 51 | 52 | return $this; 53 | } 54 | 55 | public function getEntityName(): ?string 56 | { 57 | return $this->entityName; 58 | } 59 | 60 | public function setEntityName(?string $entityName): self 61 | { 62 | $this->entityName = $entityName; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/DescribeClientQuotas/EntryData.php: -------------------------------------------------------------------------------- 1 | entity; 49 | } 50 | 51 | /** 52 | * @param EntityData[] $entity 53 | */ 54 | public function setEntity(array $entity): self 55 | { 56 | $this->entity = $entity; 57 | 58 | return $this; 59 | } 60 | 61 | /** 62 | * @return ValueData[] 63 | */ 64 | public function getValues(): array 65 | { 66 | return $this->values; 67 | } 68 | 69 | /** 70 | * @param ValueData[] $values 71 | */ 72 | public function setValues(array $values): self 73 | { 74 | $this->values = $values; 75 | 76 | return $this; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Protocol/DescribeClientQuotas/ValueData.php: -------------------------------------------------------------------------------- 1 | key; 46 | } 47 | 48 | public function setKey(string $key): self 49 | { 50 | $this->key = $key; 51 | 52 | return $this; 53 | } 54 | 55 | public function getValue(): float 56 | { 57 | return $this->value; 58 | } 59 | 60 | public function setValue(float $value): self 61 | { 62 | $this->value = $value; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/DescribeDelegationToken/DescribeDelegationTokenOwner.php: -------------------------------------------------------------------------------- 1 | principalType; 46 | } 47 | 48 | public function setPrincipalType(string $principalType): self 49 | { 50 | $this->principalType = $principalType; 51 | 52 | return $this; 53 | } 54 | 55 | public function getPrincipalName(): string 56 | { 57 | return $this->principalName; 58 | } 59 | 60 | public function setPrincipalName(string $principalName): self 61 | { 62 | $this->principalName = $principalName; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/DescribeDelegationToken/DescribeDelegationTokenRequest.php: -------------------------------------------------------------------------------- 1 | owners; 51 | } 52 | 53 | /** 54 | * @param DescribeDelegationTokenOwner[]|null $owners 55 | */ 56 | public function setOwners(?array $owners): self 57 | { 58 | $this->owners = $owners; 59 | 60 | return $this; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Protocol/DescribeDelegationToken/DescribedDelegationTokenRenewer.php: -------------------------------------------------------------------------------- 1 | principalType; 46 | } 47 | 48 | public function setPrincipalType(string $principalType): self 49 | { 50 | $this->principalType = $principalType; 51 | 52 | return $this; 53 | } 54 | 55 | public function getPrincipalName(): string 56 | { 57 | return $this->principalName; 58 | } 59 | 60 | public function setPrincipalName(string $principalName): self 61 | { 62 | $this->principalName = $principalName; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/DescribeLogDirs/DescribableLogDirTopic.php: -------------------------------------------------------------------------------- 1 | topic; 46 | } 47 | 48 | public function setTopic(string $topic): self 49 | { 50 | $this->topic = $topic; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[] 57 | */ 58 | public function getPartitionIndex(): array 59 | { 60 | return $this->partitionIndex; 61 | } 62 | 63 | /** 64 | * @param int[] $partitionIndex 65 | */ 66 | public function setPartitionIndex(array $partitionIndex): self 67 | { 68 | $this->partitionIndex = $partitionIndex; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/DescribeLogDirs/DescribeLogDirsRequest.php: -------------------------------------------------------------------------------- 1 | topics; 51 | } 52 | 53 | /** 54 | * @param DescribableLogDirTopic[]|null $topics 55 | */ 56 | public function setTopics(?array $topics): self 57 | { 58 | $this->topics = $topics; 59 | 60 | return $this; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Protocol/DescribeLogDirs/DescribeLogDirsTopic.php: -------------------------------------------------------------------------------- 1 | name; 44 | } 45 | 46 | public function setName(string $name): self 47 | { 48 | $this->name = $name; 49 | 50 | return $this; 51 | } 52 | 53 | /** 54 | * @return DescribeLogDirsPartition[] 55 | */ 56 | public function getPartitions(): array 57 | { 58 | return $this->partitions; 59 | } 60 | 61 | /** 62 | * @param DescribeLogDirsPartition[] $partitions 63 | */ 64 | public function setPartitions(array $partitions): self 65 | { 66 | $this->partitions = $partitions; 67 | 68 | return $this; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/Protocol/ElectLeaders/ReplicaElectionResult.php: -------------------------------------------------------------------------------- 1 | topic; 46 | } 47 | 48 | public function setTopic(string $topic): self 49 | { 50 | $this->topic = $topic; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return PartitionResult[] 57 | */ 58 | public function getPartitionResult(): array 59 | { 60 | return $this->partitionResult; 61 | } 62 | 63 | /** 64 | * @param PartitionResult[] $partitionResult 65 | */ 66 | public function setPartitionResult(array $partitionResult): self 67 | { 68 | $this->partitionResult = $partitionResult; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/ElectLeaders/TopicPartitions.php: -------------------------------------------------------------------------------- 1 | topic; 46 | } 47 | 48 | public function setTopic(string $topic): self 49 | { 50 | $this->topic = $topic; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[] 57 | */ 58 | public function getPartitionId(): array 59 | { 60 | return $this->partitionId; 61 | } 62 | 63 | /** 64 | * @param int[] $partitionId 65 | */ 66 | public function setPartitionId(array $partitionId): self 67 | { 68 | $this->partitionId = $partitionId; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/EndTxn/EndTxnResponse.php: -------------------------------------------------------------------------------- 1 | throttleTimeMs; 51 | } 52 | 53 | public function setThrottleTimeMs(int $throttleTimeMs): self 54 | { 55 | $this->throttleTimeMs = $throttleTimeMs; 56 | 57 | return $this; 58 | } 59 | 60 | public function getErrorCode(): int 61 | { 62 | return $this->errorCode; 63 | } 64 | 65 | public function setErrorCode(int $errorCode): self 66 | { 67 | $this->errorCode = $errorCode; 68 | 69 | return $this; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Protocol/ExpireDelegationToken/ExpireDelegationTokenRequest.php: -------------------------------------------------------------------------------- 1 | hmac; 56 | } 57 | 58 | public function setHmac(string $hmac): self 59 | { 60 | $this->hmac = $hmac; 61 | 62 | return $this; 63 | } 64 | 65 | public function getExpiryTimePeriodMs(): int 66 | { 67 | return $this->expiryTimePeriodMs; 68 | } 69 | 70 | public function setExpiryTimePeriodMs(int $expiryTimePeriodMs): self 71 | { 72 | $this->expiryTimePeriodMs = $expiryTimePeriodMs; 73 | 74 | return $this; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Protocol/Fetch/AbortedTransaction.php: -------------------------------------------------------------------------------- 1 | producerId; 46 | } 47 | 48 | public function setProducerId(int $producerId): self 49 | { 50 | $this->producerId = $producerId; 51 | 52 | return $this; 53 | } 54 | 55 | public function getFirstOffset(): int 56 | { 57 | return $this->firstOffset; 58 | } 59 | 60 | public function setFirstOffset(int $firstOffset): self 61 | { 62 | $this->firstOffset = $firstOffset; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/Fetch/FetchableTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return FetchPartition[] 57 | */ 58 | public function getFetchPartitions(): array 59 | { 60 | return $this->fetchPartitions; 61 | } 62 | 63 | /** 64 | * @param FetchPartition[] $fetchPartitions 65 | */ 66 | public function setFetchPartitions(array $fetchPartitions): self 67 | { 68 | $this->fetchPartitions = $fetchPartitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/Fetch/FetchableTopicResponse.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return FetchablePartitionResponse[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param FetchablePartitionResponse[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/Fetch/ForgottenTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[] 57 | */ 58 | public function getForgottenPartitionIndexes(): array 59 | { 60 | return $this->forgottenPartitionIndexes; 61 | } 62 | 63 | /** 64 | * @param int[] $forgottenPartitionIndexes 65 | */ 66 | public function setForgottenPartitionIndexes(array $forgottenPartitionIndexes): self 67 | { 68 | $this->forgottenPartitionIndexes = $forgottenPartitionIndexes; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/FindCoordinator/FindCoordinatorRequest.php: -------------------------------------------------------------------------------- 1 | key; 56 | } 57 | 58 | public function setKey(string $key): self 59 | { 60 | $this->key = $key; 61 | 62 | return $this; 63 | } 64 | 65 | public function getKeyType(): int 66 | { 67 | return $this->keyType; 68 | } 69 | 70 | public function setKeyType(int $keyType): self 71 | { 72 | $this->keyType = $keyType; 73 | 74 | return $this; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Protocol/Heartbeat/HeartbeatResponse.php: -------------------------------------------------------------------------------- 1 | throttleTimeMs; 51 | } 52 | 53 | public function setThrottleTimeMs(int $throttleTimeMs): self 54 | { 55 | $this->throttleTimeMs = $throttleTimeMs; 56 | 57 | return $this; 58 | } 59 | 60 | public function getErrorCode(): int 61 | { 62 | return $this->errorCode; 63 | } 64 | 65 | public function setErrorCode(int $errorCode): self 66 | { 67 | $this->errorCode = $errorCode; 68 | 69 | return $this; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Protocol/JoinGroup/JoinGroupRequestProtocol.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | public function getMetadata(): string 56 | { 57 | return $this->metadata; 58 | } 59 | 60 | public function setMetadata(string $metadata): self 61 | { 62 | $this->metadata = $metadata; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/KafkaRequest.php: -------------------------------------------------------------------------------- 1 | header = $header; 35 | $this->request = $request; 36 | $this->updateData(); 37 | } 38 | 39 | public function pack(): string 40 | { 41 | return Int32::pack($this->size) . $this->data; 42 | } 43 | 44 | private function updateData(): void 45 | { 46 | $apiVersion = $this->header->getRequestApiVersion(); 47 | $headerVersion = RequestHeader::parseVersion($apiVersion, $this->request->getFlexibleVersions()); 48 | $this->data = $this->header->pack($headerVersion) . $this->request->pack($apiVersion); 49 | $this->size = \strlen($this->data); 50 | } 51 | 52 | public function getSize(): int 53 | { 54 | return $this->size; 55 | } 56 | 57 | public function getHeader(): RequestHeader 58 | { 59 | return $this->header; 60 | } 61 | 62 | public function setHeader(RequestHeader $header): self 63 | { 64 | $this->header = $header; 65 | $this->updateData(); 66 | 67 | return $this; 68 | } 69 | 70 | public function getRequest(): AbstractRequest 71 | { 72 | return $this->request; 73 | } 74 | 75 | public function setRequest(AbstractRequest $request): self 76 | { 77 | $this->request = $request; 78 | $this->updateData(); 79 | 80 | return $this; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/Protocol/LeaderAndIsr/LeaderAndIsrTopicState.php: -------------------------------------------------------------------------------- 1 | topicName; 46 | } 47 | 48 | public function setTopicName(string $topicName): self 49 | { 50 | $this->topicName = $topicName; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return LeaderAndIsrPartitionState[] 57 | */ 58 | public function getPartitionStates(): array 59 | { 60 | return $this->partitionStates; 61 | } 62 | 63 | /** 64 | * @param LeaderAndIsrPartitionState[] $partitionStates 65 | */ 66 | public function setPartitionStates(array $partitionStates): self 67 | { 68 | $this->partitionStates = $partitionStates; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/LeaveGroup/MemberIdentity.php: -------------------------------------------------------------------------------- 1 | memberId; 46 | } 47 | 48 | public function setMemberId(string $memberId): self 49 | { 50 | $this->memberId = $memberId; 51 | 52 | return $this; 53 | } 54 | 55 | public function getGroupInstanceId(): ?string 56 | { 57 | return $this->groupInstanceId; 58 | } 59 | 60 | public function setGroupInstanceId(?string $groupInstanceId): self 61 | { 62 | $this->groupInstanceId = $groupInstanceId; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/ListGroups/ListGroupsRequest.php: -------------------------------------------------------------------------------- 1 | statesFilter; 51 | } 52 | 53 | /** 54 | * @param string[] $statesFilter 55 | */ 56 | public function setStatesFilter(array $statesFilter): self 57 | { 58 | $this->statesFilter = $statesFilter; 59 | 60 | return $this; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Protocol/ListOffset/ListOffsetTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return ListOffsetPartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param ListOffsetPartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/ListOffset/ListOffsetTopicResponse.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return ListOffsetPartitionResponse[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param ListOffsetPartitionResponse[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/ListPartitionReassignments/ListPartitionReassignmentsTopics.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[] 57 | */ 58 | public function getPartitionIndexes(): array 59 | { 60 | return $this->partitionIndexes; 61 | } 62 | 63 | /** 64 | * @param int[] $partitionIndexes 65 | */ 66 | public function setPartitionIndexes(array $partitionIndexes): self 67 | { 68 | $this->partitionIndexes = $partitionIndexes; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/ListPartitionReassignments/OngoingTopicReassignment.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return OngoingPartitionReassignment[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param OngoingPartitionReassignment[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/Metadata/MetadataRequestTopic.php: -------------------------------------------------------------------------------- 1 | name; 38 | } 39 | 40 | public function setName(string $name): self 41 | { 42 | $this->name = $name; 43 | 44 | return $this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Protocol/OffsetCommit/OffsetCommitRequestTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return OffsetCommitRequestPartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param OffsetCommitRequestPartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/OffsetCommit/OffsetCommitResponsePartition.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 46 | } 47 | 48 | public function setPartitionIndex(int $partitionIndex): self 49 | { 50 | $this->partitionIndex = $partitionIndex; 51 | 52 | return $this; 53 | } 54 | 55 | public function getErrorCode(): int 56 | { 57 | return $this->errorCode; 58 | } 59 | 60 | public function setErrorCode(int $errorCode): self 61 | { 62 | $this->errorCode = $errorCode; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/OffsetCommit/OffsetCommitResponseTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return OffsetCommitResponsePartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param OffsetCommitResponsePartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/OffsetDelete/OffsetDeleteRequest.php: -------------------------------------------------------------------------------- 1 | groupId; 56 | } 57 | 58 | public function setGroupId(string $groupId): self 59 | { 60 | $this->groupId = $groupId; 61 | 62 | return $this; 63 | } 64 | 65 | /** 66 | * @return OffsetDeleteRequestTopic[] 67 | */ 68 | public function getTopics(): array 69 | { 70 | return $this->topics; 71 | } 72 | 73 | /** 74 | * @param OffsetDeleteRequestTopic[] $topics 75 | */ 76 | public function setTopics(array $topics): self 77 | { 78 | $this->topics = $topics; 79 | 80 | return $this; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/Protocol/OffsetDelete/OffsetDeleteRequestPartition.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 38 | } 39 | 40 | public function setPartitionIndex(int $partitionIndex): self 41 | { 42 | $this->partitionIndex = $partitionIndex; 43 | 44 | return $this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Protocol/OffsetDelete/OffsetDeleteRequestTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return OffsetDeleteRequestPartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param OffsetDeleteRequestPartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/OffsetDelete/OffsetDeleteResponsePartition.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 46 | } 47 | 48 | public function setPartitionIndex(int $partitionIndex): self 49 | { 50 | $this->partitionIndex = $partitionIndex; 51 | 52 | return $this; 53 | } 54 | 55 | public function getErrorCode(): int 56 | { 57 | return $this->errorCode; 58 | } 59 | 60 | public function setErrorCode(int $errorCode): self 61 | { 62 | $this->errorCode = $errorCode; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/OffsetDelete/OffsetDeleteResponseTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return OffsetDeleteResponsePartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param OffsetDeleteResponsePartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/OffsetFetch/OffsetFetchRequestTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[] 57 | */ 58 | public function getPartitionIndexes(): array 59 | { 60 | return $this->partitionIndexes; 61 | } 62 | 63 | /** 64 | * @param int[] $partitionIndexes 65 | */ 66 | public function setPartitionIndexes(array $partitionIndexes): self 67 | { 68 | $this->partitionIndexes = $partitionIndexes; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/OffsetFetch/OffsetFetchResponseTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return OffsetFetchResponsePartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param OffsetFetchResponsePartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/OffsetForLeaderEpoch/OffsetForLeaderTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return OffsetForLeaderPartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param OffsetForLeaderPartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/OffsetForLeaderEpoch/OffsetForLeaderTopicResult.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return OffsetForLeaderPartitionResult[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param OffsetForLeaderPartitionResult[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/Produce/BatchIndexAndErrorMessage.php: -------------------------------------------------------------------------------- 1 | batchIndex; 46 | } 47 | 48 | public function setBatchIndex(int $batchIndex): self 49 | { 50 | $this->batchIndex = $batchIndex; 51 | 52 | return $this; 53 | } 54 | 55 | public function getBatchIndexErrorMessage(): ?string 56 | { 57 | return $this->batchIndexErrorMessage; 58 | } 59 | 60 | public function setBatchIndexErrorMessage(?string $batchIndexErrorMessage): self 61 | { 62 | $this->batchIndexErrorMessage = $batchIndexErrorMessage; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/Produce/PartitionProduceData.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 46 | } 47 | 48 | public function setPartitionIndex(int $partitionIndex): self 49 | { 50 | $this->partitionIndex = $partitionIndex; 51 | 52 | return $this; 53 | } 54 | 55 | public function getRecords(): ?\longlang\phpkafka\Protocol\RecordBatch\RecordBatch 56 | { 57 | return $this->records; 58 | } 59 | 60 | public function setRecords(?\longlang\phpkafka\Protocol\RecordBatch\RecordBatch $records): self 61 | { 62 | $this->records = $records; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/Produce/TopicProduceData.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return PartitionProduceData[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param PartitionProduceData[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/Produce/TopicProduceResponse.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return PartitionProduceResponse[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param PartitionProduceResponse[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/RecordBatch/Enum/Compression.php: -------------------------------------------------------------------------------- 1 | hmac; 56 | } 57 | 58 | public function setHmac(string $hmac): self 59 | { 60 | $this->hmac = $hmac; 61 | 62 | return $this; 63 | } 64 | 65 | public function getRenewPeriodMs(): int 66 | { 67 | return $this->renewPeriodMs; 68 | } 69 | 70 | public function setRenewPeriodMs(int $renewPeriodMs): self 71 | { 72 | $this->renewPeriodMs = $renewPeriodMs; 73 | 74 | return $this; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Protocol/ResponseHeader/ResponseHeader.php: -------------------------------------------------------------------------------- 1 | correlationId; 38 | } 39 | 40 | public function setCorrelationId(int $correlationId): self 41 | { 42 | $this->correlationId = $correlationId; 43 | 44 | return $this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Protocol/SaslAuthenticate/SaslAuthenticateRequest.php: -------------------------------------------------------------------------------- 1 | authBytes; 48 | } 49 | 50 | public function setAuthBytes(string $authBytes): self 51 | { 52 | $this->authBytes = $authBytes; 53 | 54 | return $this; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Protocol/SaslHandshake/SaslHandshakeRequest.php: -------------------------------------------------------------------------------- 1 | mechanism; 48 | } 49 | 50 | public function setMechanism(string $mechanism): self 51 | { 52 | $this->mechanism = $mechanism; 53 | 54 | return $this; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Protocol/SaslHandshake/SaslHandshakeResponse.php: -------------------------------------------------------------------------------- 1 | errorCode; 51 | } 52 | 53 | public function setErrorCode(int $errorCode): self 54 | { 55 | $this->errorCode = $errorCode; 56 | 57 | return $this; 58 | } 59 | 60 | /** 61 | * @return string[] 62 | */ 63 | public function getMechanisms(): array 64 | { 65 | return $this->mechanisms; 66 | } 67 | 68 | /** 69 | * @param string[] $mechanisms 70 | */ 71 | public function setMechanisms(array $mechanisms): self 72 | { 73 | $this->mechanisms = $mechanisms; 74 | 75 | return $this; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Protocol/StopReplica/StopReplicaPartitionV0.php: -------------------------------------------------------------------------------- 1 | topicName; 46 | } 47 | 48 | public function setTopicName(string $topicName): self 49 | { 50 | $this->topicName = $topicName; 51 | 52 | return $this; 53 | } 54 | 55 | public function getPartitionIndex(): int 56 | { 57 | return $this->partitionIndex; 58 | } 59 | 60 | public function setPartitionIndex(int $partitionIndex): self 61 | { 62 | $this->partitionIndex = $partitionIndex; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/StopReplica/StopReplicaTopicState.php: -------------------------------------------------------------------------------- 1 | topicName; 46 | } 47 | 48 | public function setTopicName(string $topicName): self 49 | { 50 | $this->topicName = $topicName; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return StopReplicaPartitionState[] 57 | */ 58 | public function getPartitionStates(): array 59 | { 60 | return $this->partitionStates; 61 | } 62 | 63 | /** 64 | * @param StopReplicaPartitionState[] $partitionStates 65 | */ 66 | public function setPartitionStates(array $partitionStates): self 67 | { 68 | $this->partitionStates = $partitionStates; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/StopReplica/StopReplicaTopicV1.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[] 57 | */ 58 | public function getPartitionIndexes(): array 59 | { 60 | return $this->partitionIndexes; 61 | } 62 | 63 | /** 64 | * @param int[] $partitionIndexes 65 | */ 66 | public function setPartitionIndexes(array $partitionIndexes): self 67 | { 68 | $this->partitionIndexes = $partitionIndexes; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/SyncGroup/SyncGroupRequestAssignment.php: -------------------------------------------------------------------------------- 1 | memberId; 46 | } 47 | 48 | public function setMemberId(string $memberId): self 49 | { 50 | $this->memberId = $memberId; 51 | 52 | return $this; 53 | } 54 | 55 | public function getAssignment(): string 56 | { 57 | return $this->assignment; 58 | } 59 | 60 | public function setAssignment(string $assignment): self 61 | { 62 | $this->assignment = $assignment; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/TxnOffsetCommit/TxnOffsetCommitRequestTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return TxnOffsetCommitRequestPartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param TxnOffsetCommitRequestPartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/TxnOffsetCommit/TxnOffsetCommitResponsePartition.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 46 | } 47 | 48 | public function setPartitionIndex(int $partitionIndex): self 49 | { 50 | $this->partitionIndex = $partitionIndex; 51 | 52 | return $this; 53 | } 54 | 55 | public function getErrorCode(): int 56 | { 57 | return $this->errorCode; 58 | } 59 | 60 | public function setErrorCode(int $errorCode): self 61 | { 62 | $this->errorCode = $errorCode; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/TxnOffsetCommit/TxnOffsetCommitResponseTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return TxnOffsetCommitResponsePartition[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param TxnOffsetCommitResponsePartition[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/Type/AbstractType.php: -------------------------------------------------------------------------------- 1 | self::MAX_VALUE) { 25 | throw new InvalidArgumentException(sprintf('%s is outside the range of Int16', $value)); 26 | } 27 | $result = pack(self::FORAMT, $value); 28 | if (!ProtocolUtil::nativeIsBigEndian()) { 29 | $result = strrev($result); 30 | } 31 | 32 | return $result; 33 | } 34 | 35 | public static function unpack(string $value, ?int &$size = null): int 36 | { 37 | $value = substr($value, 0, 2); 38 | if (!ProtocolUtil::nativeIsBigEndian()) { 39 | $value = strrev($value); 40 | } 41 | $size = 2; 42 | 43 | return unpack(self::FORAMT, $value)[1]; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Protocol/Type/Int32.php: -------------------------------------------------------------------------------- 1 | self::MAX_VALUE) { 25 | throw new InvalidArgumentException(sprintf('%s is outside the range of Int32', $value)); 26 | } 27 | $result = pack(self::FORAMT, $value); 28 | if (!ProtocolUtil::nativeIsBigEndian()) { 29 | $result = strrev($result); 30 | } 31 | 32 | return $result; 33 | } 34 | 35 | public static function unpack(string $value, ?int &$size = null): int 36 | { 37 | $value = substr($value, 0, 4); 38 | if (!ProtocolUtil::nativeIsBigEndian()) { 39 | $value = strrev($value); 40 | } 41 | $size = 4; 42 | 43 | return unpack(self::FORAMT, $value)[1]; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Protocol/Type/Int64.php: -------------------------------------------------------------------------------- 1 | self::MAX_VALUE) { 25 | throw new InvalidArgumentException(sprintf('%s is outside the range of Int64', $value)); 26 | } 27 | $result = pack(self::FORAMT, $value); 28 | if (!ProtocolUtil::nativeIsBigEndian()) { 29 | $result = strrev($result); 30 | } 31 | 32 | return $result; 33 | } 34 | 35 | public static function unpack(string $value, ?int &$size = null): int 36 | { 37 | $value = substr($value, 0, 8); 38 | if (!ProtocolUtil::nativeIsBigEndian()) { 39 | $value = strrev($value); 40 | } 41 | $size = 8; 42 | 43 | return unpack(self::FORAMT, $value)[1]; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Protocol/Type/Int8.php: -------------------------------------------------------------------------------- 1 | self::MAX_VALUE) { 24 | throw new InvalidArgumentException(sprintf('%s is outside the range of Int8', $value)); 25 | } 26 | 27 | return pack(self::FORAMT, $value); 28 | } 29 | 30 | public static function unpack(string $value, ?int &$size = null): int 31 | { 32 | $size = 1; 33 | 34 | return unpack(self::FORAMT, $value)[1]; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Protocol/Type/NullableString.php: -------------------------------------------------------------------------------- 1 | phptype, uncompactType, compactType, nullableType, compactNullableType 21 | '[]' => ['array', 'ArrayInt32', 'CompactArray', 'ArrayInt32', 'CompactArray'], 22 | 'bool' => ['bool', 'Boolean', 'Boolean', 'Boolean', 'Boolean'], 23 | 'float64' => ['float', 'Float64', 'Float64', 'Float64', 'Float64'], 24 | 'int8' => ['int', 'Int8', 'Int8', 'Int8', 'Int8'], 25 | 'int16' => ['int', 'Int16', 'Int16', 'Int16', 'Int16'], 26 | 'int32' => ['int', 'Int32', 'Int32', 'Int32', 'Int32'], 27 | 'int64' => ['int', 'Int64', 'Int64', 'Int64', 'Int64'], 28 | 'string' => ['string', 'String16', 'CompactString', 'NullableString', 'CompactNullableString'], 29 | 'bytes' => ['string', 'String32', 'CompactString', 'NullableString32', 'CompactNullableString'], 30 | 'varint' => ['int', 'varint', 'varint', 'varint', 'varint'], 31 | 'RecordBatch' => ['\longlang\phpkafka\Protocol\RecordBatch\RecordBatch', '\longlang\phpkafka\Protocol\RecordBatch\RecordBatch', '\longlang\phpkafka\Protocol\RecordBatch\RecordBatch', '\longlang\phpkafka\Protocol\RecordBatch\RecordBatch'], 32 | ]; 33 | 34 | private function __construct() 35 | { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Protocol/Type/UInt32.php: -------------------------------------------------------------------------------- 1 | self::MAX_VALUE) { 24 | throw new InvalidArgumentException(sprintf('%s is outside the range of UInt32', $value)); 25 | } 26 | 27 | return pack(self::FORAMT, $value); 28 | } 29 | 30 | public static function unpack(string $value, ?int &$size = null): int 31 | { 32 | $size = 4; 33 | 34 | return unpack(self::FORAMT, $value)[1]; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Protocol/Type/UVarInt.php: -------------------------------------------------------------------------------- 1 | self::MAX_VALUE) { 23 | throw new InvalidArgumentException(sprintf('%s is outside the range of VarInt', $value)); 24 | } 25 | $buffer = ''; 26 | while (0 != ($value & 0xffffff80)) { 27 | $b = \chr(($value & 0x7f) | 0x80); 28 | $buffer .= $b; 29 | $value = ProtocolUtil::shr32($value, 7); 30 | } 31 | $buffer .= \chr($value); 32 | 33 | return $buffer; 34 | } 35 | 36 | public static function unpack(string $value, ?int &$size = null): int 37 | { 38 | $result = 0; 39 | $i = 0; 40 | $size = 0; 41 | while (0 != (($b = \ord($value[$size++])) & 0x80)) { 42 | $result |= ($b & 0x7f) << $i; 43 | $i += 7; 44 | if ($i > 28) { 45 | throw new \InvalidArgumentException('illegal Varint'); 46 | } 47 | } 48 | $result |= $b << $i; 49 | 50 | return $result; 51 | } 52 | 53 | public static function size(int $value): int 54 | { 55 | if (\PHP_INT_SIZE == 4 && $value < 0) { 56 | return 5; 57 | } 58 | if ($value < (1 << 7)) { 59 | return 1; 60 | } 61 | if ($value < (1 << 14)) { 62 | return 2; 63 | } 64 | if ($value < (1 << 21)) { 65 | return 3; 66 | } 67 | if ($value < (1 << 28)) { 68 | return 4; 69 | } 70 | 71 | return 5; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Protocol/Type/VarInt.php: -------------------------------------------------------------------------------- 1 | > 31)); 18 | } 19 | 20 | public static function unpack(string $value, ?int &$size = null): int 21 | { 22 | $result = UVarInt::unpack($value, $size); 23 | 24 | return ProtocolUtil::shr32($result, 1) ^ -($result & 1); 25 | } 26 | 27 | private function __construct() 28 | { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Protocol/UpdateMetadata/UpdateMetadataResponse.php: -------------------------------------------------------------------------------- 1 | errorCode; 43 | } 44 | 45 | public function setErrorCode(int $errorCode): self 46 | { 47 | $this->errorCode = $errorCode; 48 | 49 | return $this; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Protocol/UpdateMetadata/UpdateMetadataTopicState.php: -------------------------------------------------------------------------------- 1 | topicName; 46 | } 47 | 48 | public function setTopicName(string $topicName): self 49 | { 50 | $this->topicName = $topicName; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return UpdateMetadataPartitionState[] 57 | */ 58 | public function getPartitionStates(): array 59 | { 60 | return $this->partitionStates; 61 | } 62 | 63 | /** 64 | * @param UpdateMetadataPartitionState[] $partitionStates 65 | */ 66 | public function setPartitionStates(array $partitionStates): self 67 | { 68 | $this->partitionStates = $partitionStates; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/WriteTxnMarkers/WritableTxnMarkerPartitionResult.php: -------------------------------------------------------------------------------- 1 | partitionIndex; 46 | } 47 | 48 | public function setPartitionIndex(int $partitionIndex): self 49 | { 50 | $this->partitionIndex = $partitionIndex; 51 | 52 | return $this; 53 | } 54 | 55 | public function getErrorCode(): int 56 | { 57 | return $this->errorCode; 58 | } 59 | 60 | public function setErrorCode(int $errorCode): self 61 | { 62 | $this->errorCode = $errorCode; 63 | 64 | return $this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Protocol/WriteTxnMarkers/WritableTxnMarkerResult.php: -------------------------------------------------------------------------------- 1 | producerId; 46 | } 47 | 48 | public function setProducerId(int $producerId): self 49 | { 50 | $this->producerId = $producerId; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return WritableTxnMarkerTopicResult[] 57 | */ 58 | public function getTopics(): array 59 | { 60 | return $this->topics; 61 | } 62 | 63 | /** 64 | * @param WritableTxnMarkerTopicResult[] $topics 65 | */ 66 | public function setTopics(array $topics): self 67 | { 68 | $this->topics = $topics; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/WriteTxnMarkers/WritableTxnMarkerTopic.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return int[] 57 | */ 58 | public function getPartitionIndexes(): array 59 | { 60 | return $this->partitionIndexes; 61 | } 62 | 63 | /** 64 | * @param int[] $partitionIndexes 65 | */ 66 | public function setPartitionIndexes(array $partitionIndexes): self 67 | { 68 | $this->partitionIndexes = $partitionIndexes; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/WriteTxnMarkers/WritableTxnMarkerTopicResult.php: -------------------------------------------------------------------------------- 1 | name; 46 | } 47 | 48 | public function setName(string $name): self 49 | { 50 | $this->name = $name; 51 | 52 | return $this; 53 | } 54 | 55 | /** 56 | * @return WritableTxnMarkerPartitionResult[] 57 | */ 58 | public function getPartitions(): array 59 | { 60 | return $this->partitions; 61 | } 62 | 63 | /** 64 | * @param WritableTxnMarkerPartitionResult[] $partitions 65 | */ 66 | public function setPartitions(array $partitions): self 67 | { 68 | $this->partitions = $partitions; 69 | 70 | return $this; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Protocol/WriteTxnMarkers/WriteTxnMarkersRequest.php: -------------------------------------------------------------------------------- 1 | markers; 51 | } 52 | 53 | /** 54 | * @param WritableTxnMarker[] $markers 55 | */ 56 | public function setMarkers(array $markers): self 57 | { 58 | $this->markers = $markers; 59 | 60 | return $this; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Protocol/WriteTxnMarkers/WriteTxnMarkersResponse.php: -------------------------------------------------------------------------------- 1 | markers; 46 | } 47 | 48 | /** 49 | * @param WritableTxnMarkerResult[] $markers 50 | */ 51 | public function setMarkers(array $markers): self 52 | { 53 | $this->markers = $markers; 54 | 55 | return $this; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Sasl/PlainSasl.php: -------------------------------------------------------------------------------- 1 | config = $config; 20 | } 21 | 22 | /** 23 | * 授权模式. 24 | */ 25 | public function getName(): string 26 | { 27 | return 'PLAIN'; 28 | } 29 | 30 | /** 31 | * 获得加密串. 32 | */ 33 | public function getAuthBytes(): string 34 | { 35 | $config = $this->config->getSasl(); 36 | if (empty($config['username']) || empty($config['password'])) { 37 | // 不存在就报错 38 | throw new KafkaErrorException('sasl not found auth info'); 39 | } 40 | 41 | return sprintf("\x00%s\x00%s", $config['username'], $config['password']); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Sasl/SaslInterface.php: -------------------------------------------------------------------------------- 1 |