Kafka\Protocol\Encoder::_encodeCommitOffsetPartion PHP Method

_encodeCommitOffsetPartion() protected static method

encode signal part
protected static _encodeCommitOffsetPartion ( $values ) : string
return string
    protected static function _encodeCommitOffsetPartion($values)
    {
        if (!isset($values['partition_id'])) {
            throw new \Kafka\Exception\Protocol('given commit offset data invalid. `partition_id` is undefined.');
        }
        if (!isset($values['offset'])) {
            throw new \Kafka\Exception\Protocol('given commit offset data invalid. `offset` is undefined.');
        }
        if (!isset($values['time'])) {
            $values['time'] = -1;
        }
        if (!isset($values['metadata'])) {
            $values['metadata'] = 'm';
        }
        $data = self::pack(self::BIT_B32, $values['partition_id']);
        $data .= self::pack(self::BIT_B64, $values['offset']);
        $data .= self::pack(self::BIT_B64, $values['time']);
        $data .= self::encodeString($values['metadata'], self::PACK_INT16);
        return $data;
    }

Usage Example

Example #1
0
 /**
  * encodeCommitOffsetPartion
  *
  * @access public
  * @return void
  */
 public static function encodeCommitOffsetPartion($values)
 {
     return parent::_encodeCommitOffsetPartion($values);
 }