Skip to content

Commit

Permalink
Merge pull request #4 in PH/phpkafka from intern-master to master
Browse files Browse the repository at this point in the history
* commit '8bd35ce63f0183d6482e3e604df28b888e548fed':
  Fix syntax in test script + make void methods chainable (setPartition)
  • Loading branch information
Elias Van Ootegem committed Apr 3, 2015
2 parents 6b06954 + 8bd35ce commit 195e4c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions php_kafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ PHP_METHOD(Kafka, __destruct)
}
/* }}} end Kafka::__destruct */

/* {{{ proto void Kafka::set_partition( int $partition );
/* {{{ proto Kafka Kafka::set_partition( int $partition );
Set partition (used by consume method)
This method is deprecated, in favour of the more PSR-compliant
Kafka::setPartition
Expand All @@ -146,10 +146,11 @@ PHP_METHOD(Kafka, set_partition)
kafka_set_partition(Z_LVAL_P(partition));
//update partition property, so we can check to see if it's set when consuming
zend_update_property(kafka_ce, getThis(), "partition", sizeof("partition") -1, partition TSRMLS_CC);
RETURN_ZVAL(getThis(), 1, 0);
}
/* }}} end Kafka::set_partition */

/* {{{ proto void Kafka::setPartition( int $partition );
/* {{{ proto Kafka Kafka::setPartition( int $partition );
Set partition to use for Kafka::consume calls
*/
PHP_METHOD(Kafka, setPartition)
Expand All @@ -166,6 +167,8 @@ PHP_METHOD(Kafka, setPartition)
}
kafka_set_partition(Z_LVAL_P(partition));
zend_update_property(kafka_ce, getThis(), "partition", sizeof("partition") -1, partition TSRMLS_CC);
//return $this
RETURN_ZVAL(getThis(), 1, 0);
}
/* }}} end Kafka::setPartition */

Expand Down Expand Up @@ -199,7 +202,7 @@ PHP_METHOD(Kafka, disconnect)
}
/* }}} end Kafka::disconnect */

/* {{{ proto void Kafka::produce( string $topic, string $message);
/* {{{ proto Kafka Kafka::produce( string $topic, string $message);
Produce a message, returns int (partition used to produce)
or false if something went wrong
*/
Expand All @@ -219,6 +222,7 @@ PHP_METHOD(Kafka, produce)
}

kafka_produce(topic, msg, msg_len);
RETURN_ZVAL(object, 1, 0);
}
/* }}} end Kafka::produce */

Expand Down Expand Up @@ -259,9 +263,5 @@ PHP_METHOD(Kafka, consume)

array_init(return_value);
kafka_consume(return_value, topic, offset, count);

if(return_value == NULL) {
RETURN_FALSE;
}
}
/* }}} end Kafka::consume */
6 changes: 3 additions & 3 deletions test2.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
);
$kafka->produce($topic, $msg);
echo 'Done', PHP_EOL;
echo 'Listing partitions for topic ', $topic, PHP_EOL
echo 'Listing partitions for topic ', $topic, PHP_EOL;
var_dump($kafka->getPartitionsForTopic('eliasTest'));
echo 'Closing, and reopening connection', PHP_EOL
echo 'Closing, and reopening connection', PHP_EOL;
$kafka = new \Kafka("kafka-1:9092,kafka-2:9092");
echo 'Done... Now selecting partition 2', PHP_EOL;
$kafka->setPartition(2);
Expand All @@ -24,7 +24,7 @@
$end - $start,
$read ? ($end - $start)/$read : 0
);
echo 'Dumping messages'
echo 'Dumping messages';
var_dump($cons);
echo 'Closing connection', PHP_EOL;
$kafka->disconnect();
Expand Down

0 comments on commit 195e4c0

Please sign in to comment.