public function receive() { // Read response length $responseLength = $this->client->read(4); $responseLength = Packer::unpackSignedInt32($responseLength); Logger::log('Reponse length: %s', var_export($responseLength, true)); // Read response $response = $this->client->read($responseLength); Logger::log('Response (packed): %s', var_export($response, true)); $cursor = 0; // Read CorrelationId $correlationId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> CorrelationId: %s', var_export($correlationId, true)); $cursor += 4; // Read ErrorCode $errorCode = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log('> ErrorCode: %s', var_export($errorCode, true)); $cursor += 2; // Read MemberAssignment length $memberAssignmentLength = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> MemberAssignment length: %s', var_export($memberAssignmentLength, true)); $cursor += 4; // Read MemberAssignment $memberAssignment = substr($response, $cursor, $memberAssignmentLength); Logger::log('> MemberAssignment: %s', var_export($memberAssignment, true)); $cursor += $memberAssignmentLength; return ['CorrelationId' => $correlationId, 'ErrorCode' => $errorCode, 'MemberAssignment' => $memberAssignment]; }
public function testMinSignedInt32() { $minSignedInt32 = -0x80000000; $packedMinSignedInt32 = Packer::packSignedInt32($minSignedInt32); $unpackedMinSignedInt32 = Packer::unpackSignedInt32($packedMinSignedInt32); $this->assertSame($minSignedInt32, $unpackedMinSignedInt32); }
public function receive() { // Read response length $responseLength = $this->client->read(4); $responseLength = Packer::unpackSignedInt32($responseLength); Logger::log('Response length: %s', var_export($responseLength, true)); // Read response $response = $this->client->read($responseLength); Logger::log('Response (packed): %s', var_export($response, true)); $cursor = 0; // Read CorrelationId $correlationId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> CorrelationId: %s', var_export($correlationId, true)); $cursor += 4; // Read ErrorCode $errorCode = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log('> ErrorCode: %s', var_export($errorCode, true)); $cursor += 2; // Read Group count $groupCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> Group count: %s', var_export($groupCount, true)); $cursor += 4; $groups = []; // Read Groups for ($i = 1; $i <= $groupCount; $i++) { Logger::log(' > [Group #%d]', $i); // Read GroupId length $groupIdLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > GroupId length: %s', var_export($groupIdLength, true)); $cursor += 2; // Read GroupId $groupId = substr($response, $cursor, $groupIdLength); Logger::log(' > GroupId: %s', var_export($groupId, true)); $cursor += $groupIdLength; // Read ProtocolType length $protocolTypeLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > ProtocolType length: %s', var_export($protocolTypeLength, true)); $cursor += 2; // Read ProtocolType $protocolType = substr($response, $cursor, $protocolTypeLength); Logger::log(' > ProtocolType: %s', var_export($protocolType, true)); $cursor += $protocolTypeLength; $groups[] = ['GroupId' => $groupId, 'ProtocolType' => $protocolType]; } return ['CorrelationId' => $correlationId, 'ErrorCode' => $errorCode, 'Groups' => $groups]; }
public function receive() { // Read response length $responseLength = $this->client->read(4); $responseLength = Packer::unpackSignedInt32($responseLength); Logger::log('Response length: %s', var_export($responseLength, true)); // Read response $response = $this->client->read($responseLength); Logger::log('Response (packed): %s', var_export($response, true)); $cursor = 0; // Read CorrelationId $correlationId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> CorrelationId: %s', var_export($correlationId, true)); $cursor += 4; // Read ErrorCode $errorCode = Packer::unpackSignedInt16(substr($response, $cursor, 4)); Logger::log('> ErrorCode: %s', var_export($errorCode, true)); $cursor += 2; // Read CoordinatorId $coordinatorId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> CoordinatorId: %s', var_export($coordinatorId, true)); $cursor += 4; // Read CoordinatorHost length $coordinatorHostLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log('> CoordinatorHost length: %s', var_export($coordinatorHostLength, true)); $cursor += 2; // Read CoordinatorHost $coordinatorHost = substr($response, $cursor, $coordinatorHostLength); Logger::log('> CoordinatorHost: %s', var_export($coordinatorHost, true)); $cursor += $coordinatorHostLength; // Read CoordinatorPort $coordinatorPort = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> CoordinatorPort: %s', var_export($coordinatorPort, true)); $cursor += 4; return ['CorrelationId' => $correlationId, 'ErrorCode' => $errorCode, 'CoordinatorId' => $coordinatorId, 'CoordinatorHost' => $coordinatorHost, 'CoordinatorPort' => $coordinatorPort]; }
public function receive() { // Read response length $responseLength = $this->client->read(4); $responseLength = Packer::unpackSignedInt32($responseLength); Logger::log('Response length: %s', var_export($responseLength, true)); // Read response $response = $this->client->read($responseLength); Logger::log('Response (packed): %s', var_export($response, true)); $cursor = 0; // Read CorrelationId $correlationId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> CorrelationId: %s', var_export($correlationId, true)); $cursor += 4; // Read Topic count $topicCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> Topic count: %s', var_export($topicCount, true)); $cursor += 4; // Read Topics $topics = []; for ($i = 1; $i <= $topicCount; $i++) { // Read Topic length $topicLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > Topic length: %s', var_export($topicLength, true)); $cursor += 2; // Read Topic $topic = substr($response, $cursor, $topicLength); Logger::log(' > Topic: %s', var_export($topic, true)); $cursor += $topicLength; // Read Parition count $partitionCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Partition count: %s', var_export($partitionCount, true)); $cursor += 4; // Read Partitions $partitions = []; for ($j = 1; $j <= $partitionCount; $j++) { Logger::log(' > [Partition #%d]', $j); // Read Partition $partitionId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > PartitionId: %s', var_export($partitionId, true)); $cursor += 4; // Read Offset $offset = Packer::unpackSignedInt64(substr($response, $cursor, 8)); Logger::log(' > Offset: %s', var_export($offset, true)); $cursor += 8; // Read Metadata length $metadataLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > Metadata length: %s', var_export($metadataLength, true)); $cursor += 2; // Read Metadata $metadata = substr($response, $cursor, $metadataLength); Logger::log(' > Metadata: %s', var_export($metadata, true)); $cursor += $metadataLength; // Read ErrorCode $errorCode = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > ErrorCode: %s', var_export($errorCode, true)); $cursor += 2; $partitions[$partitionId] = ['PartitionId' => $partitionId, 'Offset' => $offset, 'Metadata' => $metadata, 'ErrorCode' => $errorCode]; } $topics[$topic] = ['Topic' => $topic, 'Partitions' => $partitions]; } return ['CorrelationId' => $correlationId, 'Topics' => $topics]; }
public function receive() { // Read response length $responseLength = $this->client->read(4); $responseLength = Packer::unpackSignedInt32($responseLength); Logger::log('Response length: %s', var_export($responseLength, true)); // Read response $response = $this->client->read($responseLength); Logger::log('Response (packed): %s', var_export($response, true)); $cursor = 0; // Read CorrelationId $correlationId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> CorrelationId: %s', var_export($correlationId, true)); $cursor += 4; // Read ErrorCode $errorCode = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log('> ErrorCode: %s', var_export($errorCode, true)); $cursor += 2; // Read GenerationId $generationId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> GenerationId: %s', var_export($generationId, true)); $cursor += 4; // Read GroupProtocol length $groupProtocolLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log('> GroupProtocol length: %s', var_export($groupProtocolLength, true)); $cursor += 2; // Read GroupProtocol $groupProtocol = substr($response, $cursor, $groupProtocolLength); Logger::log('> GroupProtocol: %s', var_export($groupProtocol, true)); $cursor += $groupProtocolLength; // Read LeaderId length $leaderIdLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log('> LeaderId length: %s', var_export($leaderIdLength, true)); $cursor += 2; // Read LeaderId $leaderId = substr($response, $cursor, $leaderIdLength); Logger::log('> LeaderId: %s', var_export($leaderId, true)); $cursor += $leaderIdLength; // Read MemberId length $memberIdLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log('> MemberId length: %s', var_export($memberIdLength, true)); $cursor += 2; // Read MemberId $memberId = substr($response, $cursor, $memberIdLength); Logger::log('> MemberId: %s', var_export($memberIdLength, true)); $cursor += $memberIdLength; // Read Member count $memberCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> Member count: %s', var_export($memberCount, true)); $cursor += 4; // Read Members $members = []; for ($i = 1; $i <= $memberCount; $i++) { Logger::log(' > [Member #%d]', $i); // Read MemberId length $memberIdLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > MemberId length: %s', var_export($memberIdLength, true)); $cursor += 2; // Read MemberId $memberId = substr($response, $cursor, $memberIdLength); Logger::log(' > MemberId: %s', var_export($memberIdLength, true)); $cursor += $memberIdLength; // TODO: read MemberMetaData // Read MemberMetaData size $memberMetaDataSize = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > MemberMetaData size: %s', var_export($memberMetaDataSize, true)); $cursor += 4; // Read MemberMetaData $memberMetaData = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > MemberMetaData: %s', var_export($memberMetaData, true)); $cursor += $memberMetaDataSize; $members[] = ['MemberId' => $memberId, 'MemberMetaData' => $memberMetaData]; } return ['CorrelationId' => $correlationId, 'ErrorCode' => $errorCode, 'GenerationId' => $generationId, 'GroupProtocol' => $groupProtocol, 'LeaderId' => $leaderId, 'MemberId' => $memberId, 'Members' => $members]; }
public function receive() { // Read response length $responseLength = $this->client->read(4); $responseLength = Packer::unpackSignedInt32($responseLength); Logger::log('Response length: %s', var_export($responseLength, true)); // Response $response = $this->client->read($responseLength); Logger::log('Response (packed): %s', var_export($response, true)); $cursor = 0; // Read CorrelationId $correlationId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> CorrelationId: %s', var_export($correlationId, true)); $cursor += 4; // Read Broker count $brokerCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> Broker count: %s', var_export($brokerCount, true)); $cursor += 4; // Read Brokers $brokers = []; for ($i = 1; $i <= $brokerCount; $i++) { Logger::log(' > [Broker #%d]', $i); // Read NodeId $nodeId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > NodeId: %s', var_export($nodeId, true)); $cursor += 4; // Read Host length $hostLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > Host length: %s', var_export($hostLength, true)); $cursor += 2; // Read Host $host = substr($response, $cursor, $hostLength); Logger::log(' > Host: %s', var_export($host, true)); $cursor += $hostLength; // Read Port $port = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Port: %s', var_export($port, true)); $cursor += 4; $brokers[] = ['NodeId' => $nodeId, 'Host' => $host, 'Port' => $port]; } // Read TopicMetadata count $topicMetadataCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> TopicMetadata count: %s', var_export($topicMetadataCount, true)); $cursor += 4; // Read TopicMetadata $topicMetadatas = []; for ($i = 1; $i <= $topicMetadataCount; $i++) { Logger::log(' > [TopicMetadata #%d]', $i); // Read TopicErrorCode $topicErrorCode = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > TopicErrorCode: %s', var_export($topicErrorCode, true)); $cursor += 2; // Read Topic length $topicLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > Topic length: %s', var_export($topicLength, true)); $cursor += 2; // Read Topic $topic = substr($response, $cursor, $topicLength); Logger::log(' > Topic: %s', var_export($topic, true)); $cursor += $topicLength; // Read PartitionMetadata count $partitionMetadataCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > PartitionMetadata count: %s', var_export($partitionMetadataCount, true)); $cursor += 4; // Read PartitionMetadata $partitionMetadatas = []; for ($j = 1; $j <= $partitionMetadataCount; $j++) { Logger::log(' > [PartitionMetadata #%d]', $j); // Read PartitionErrorCode $partitionErrorCode = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > PartitionErrorCode: %s', var_export($partitionErrorCode, true)); $cursor += 2; // Read PartitionId $partitionId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > PartitionId: %s', var_export($partitionId, true)); $cursor += 4; // Read Leader $leaderId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > LeaderId: %s', var_export($leaderId, true)); $cursor += 4; // Read Replica count $replicaCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Replica count: %s', var_export($replicaCount, true)); $cursor += 4; // Read Replicas $replicas = []; for ($k = 1; $k <= $replicaCount; $k++) { Logger::log(' > [Replica #%d]', $k); // Read Replica $replica = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Replica: %s', var_export($replica, true)); $cursor += 4; $replicas[] = $replica; } // Read Isr count $isrCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Isr count: %s', var_export($isrCount, true)); $cursor += 4; // Read Isrs $isrs = []; for ($k = 1; $k <= $isrCount; $k++) { Logger::log(' > [Isr #%d]', $k); // Read Isr $isr = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Isr: %s', var_export($isr, true)); $cursor += 4; $isrs[] = $isr; } $partitionMetadatas[] = ['ErrorCode' => $partitionErrorCode, 'PartitionId' => $partitionId, 'LeaderId' => $leaderId, 'Replica' => $replicas, 'Isr' => $isrs]; } $topicMetadatas[] = ['ErrorCode' => $topicErrorCode, 'Topic' => $topic, 'PartitionMetadata' => $partitionMetadatas]; } return ['CorrelationId' => $correlationId, 'Brokers' => $brokers, 'TopicMetadata' => $topicMetadatas]; }
public function receive() { // Read response length $responseLength = $this->client->read(4); $responseLength = Packer::unpackSignedInt32($responseLength); Logger::log('Response length: %s', var_export($responseLength, true)); // Read response $response = $this->client->read($responseLength); Logger::log('Response (packed): %s', var_export($response, true)); $cursor = 0; // Read CorrelationId $correlationId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> CorrelationId: %s', var_export($correlationId, true)); $cursor += 4; // Read Group count $groupCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> Group count: %s', var_export($groupCount, true)); $cursor += 4; // Read Groups $groups = []; for ($i = 1; $i <= $groupCount; $i++) { Logger::log(' > [Group #%d]', $i); // Read ErrorCode $errorCode = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > ErrorCode: %s', var_export($errorCode, true)); $cursor += 2; // Read GroupId length $groupIdLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > GroupId length: %s', var_export($groupIdLength, true)); $cursor += 2; // Read GroupId $groupId = substr($response, $cursor, $groupIdLength); Logger::log(' > GroupId: %s', var_export($groupId, true)); $cursor += $groupIdLength; // Read State length $stateLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > State length: %s', var_export($stateLength, true)); $cursor += 2; // Read State $state = substr($response, $cursor, $stateLength); Logger::log(' > State: %s', var_export($state, true)); $cursor += $stateLength; // Read ProtocolType length $protocolTypeLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > ProtocolType length: %s', var_export($protocolTypeLength, true)); $cursor += 2; // Read ProtocolType $protocolType = substr($response, $cursor, $protocolTypeLength); Logger::log(' > ProtocolType: %s', var_export($protocolType, true)); $cursor += $protocolTypeLength; // Read Protocol length $protocolLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > Protocol length: %s', var_export($protocolLength, true)); $cursor += 2; // Read Protocol $protocol = substr($response, $cursor, $protocolLength); Logger::log(' > Protocol: %s', var_export($protocol, true)); $cursor += $protocolLength; // Read Member count $memberCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Member count: %s', var_export($memberCount, true)); $cursor += 4; // Read Members $members = []; for ($j = 1; $j <= $memberCount; $j++) { Logger::log(' > [Member #%d]', $j); // Read MemberId length $memberIdLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > MemberId length: %s', var_export($memberIdLength, true)); $cursor += 2; // Read MemberId $memberId = substr($response, $cursor, $memberIdLength); Logger::log(' > MemberId: %s', var_export($memberId, true)); $cursor += $memberIdLength; // Read ClientId length $clientIdLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > ClientId length: %s', var_export($clientIdLength, true)); $cursor += 2; // Read ClientId $clientId = substr($response, $cursor, $clientIdLength); Logger::log(' > ClientId: %s', var_export($clientId, true)); $cursor += $clientIdLength; // Read ClientHost length $clientHostLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > ClientHost length: %s', var_export($clientHostLength, true)); $cursor += 2; // Read ClientHost $clientHost = substr($response, $cursor, $clientHostLength); Logger::log(' > ClientHost: %s', var_export($clientHost, true)); $cursor += $clientHostLength; // Read MemberMetadata length $memberMetadataLength = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > MemberMetadata length: %s', var_export($memberMetadataLength, true)); $cursor += 4; // Read MemberMetadata $memberMetadata = substr($response, $cursor, $memberMetadataLength); Logger::log(' > MemberMetadata: %s', var_export($memberMetadata, true)); $cursor += $memberMetadataLength; // Read MemberAssignment length $memberAssignmentLength = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > MemberAssignment length: %s', var_export($memberAssignmentLength, true)); $cursor += 4; // Read MemberAssignment $memberAssignment = substr($response, $cursor, $memberAssignmentLength); Logger::log(' > MemberAssignment: %s', var_export($memberAssignment, true)); $cursor += $memberAssignmentLength; $members[] = ['MemberId' => $memberId, 'ClientId' => $clientId, 'ClientHost' => $clientHost, 'MemberMetadata' => $memberMetadata, 'MemberAssignment' => $memberAssignment]; } $groups[] = ['ErrorCode' => $errorCode, 'GroupId' => $groupId, 'State' => $state, 'ProtocolType' => $protocolType, 'Protocol' => $protocol, 'Members' => $members]; } return ['CorrelationId' => $correlationId, 'Groups' => $groups]; }
public function receive($yield = false) { // Read response length $responseLength = $this->client->read(4); $responseLength = Packer::unpackSignedInt32($responseLength); Logger::log('Response length: %s', var_export($responseLength, true)); // Read response $response = $this->client->read($responseLength); Logger::log('Response (packed): %s', var_export($response, true)); $cursor = 0; // Read CorrelationId $correlationId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> CorrelationId: %s', var_export($correlationId, true)); $cursor += 4; // Read Topics count $topicCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log('> Topic count: %s', var_export($topicCount, true)); $cursor += 4; // Read Topics $topics = []; for ($i = 1; $i <= $topicCount; $i++) { Logger::log(' > [Topic #%d]', $i); // Read Topic length $topicLength = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > Topic length: %s', var_export($topicLength, true)); $cursor += 2; // Read Topic $topic = substr($response, $cursor, $topicLength); Logger::log(' > Topic: %s', var_export($topic, true)); $cursor += $topicLength; // Read Partition count $partitionCount = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Partition count: %s', var_export($partitionCount, true)); $cursor += 4; // Read Partitions $partitions = []; for ($j = 1; $j <= $partitionCount; $j++) { Logger::log(' > [Partition #%d]', $j); // Read Partition $partitionId = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > PartitionId: %s', var_export($partitionId, true)); $cursor += 4; // Read ErrorCode $errorCode = Packer::unpackSignedInt16(substr($response, $cursor, 2)); Logger::log(' > ErrorCode: %s', var_export($errorCode, true)); $cursor += 2; // Read HighwaterMarkOffset $highwaterMarkOffset = Packer::unpackSignedInt64(substr($response, $cursor, 8)); Logger::log(' > HighwaterMarkOffset: %s', var_export($highwaterMarkOffset, true)); $cursor += 8; // Read MessageSet length $messageSetLength = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > MessageSet length: %s', var_export($messageSetLength, true)); $cursor += 4; $read = 0; $numMessages = 0; $messageSet = []; while ($read !== $messageSetLength) { Logger::log(' > [Message #%d]', $numMessages); // Read Offset $offset = Packer::unpackSignedInt64(substr($response, $cursor, 8)); Logger::log(' > Offset: %s', var_export($offset, true)); $cursor += 8; $read += 8; // Read Message size $messageSize = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Message size: %s', var_export($messageSize, true)); $cursor += 4; $read += 4; // Read CRC $crc = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > CRC: %s', var_export($crc, true)); $cursor += 4; $read += 4; // Read MagicByte $magicByte = Packer::unpackSignedInt8(substr($response, $cursor, 1)); Logger::log(' > MagicByte: %s', var_export($magicByte, true)); $cursor += 1; $read += 1; // Read Attributes $attributes = Packer::unpackSignedInt8(substr($response, $cursor, 1)); Logger::log(' > Attributes: %s', var_export($attributes, true)); $cursor += 1; $read += 1; // Read Key size $keySize = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Key size: %s', var_export($keySize, true)); $cursor += 4; $read += 4; // Read Key if ($keySize !== -1) { $key = substr($response, $cursor, $keySize); $cursor += $keySize; $read += $keySize; } else { $key = null; } // Read Value length $valueLength = Packer::unpackSignedInt32(substr($response, $cursor, 4)); Logger::log(' > Value length: %s', var_export($valueLength, true)); $cursor += 4; $read += 4; // Read Value $value = substr($response, $cursor, $valueLength); Logger::log(' > Value: %s', var_export($value, true)); $cursor += $valueLength; $read += $valueLength; $numMessages++; if ($yield) { (yield ['Offset' => $offset, 'CRC' => $crc, 'MagicByte' => $magicByte, 'Attributes' => $attributes, 'Key' => $key, 'Value' => $value]); } $messageSet[] = ['Offset' => $offset, 'CRC' => $crc, 'MagicByte' => $magicByte, 'Attributes' => $attributes, 'Key' => $key, 'Value' => $value]; } $partitions[] = ['PartitionId' => $partitionId, 'ErrorCode' => $errorCode, 'HighwaterMarkOffset' => $highwaterMarkOffset, 'MessageSet' => $messageSet]; } $topics[] = ['Topic' => $topic, 'Partitions' => $partitions]; } if (!$yield) { (yield ['CorrelationId' => $correlationId, 'Topics' => $topics]); } }