Skip to content

Commit cb53a54

Browse files
authored
small fixes (#33)
* save work * fix comment
1 parent b030784 commit cb53a54

9 files changed

+60
-57
lines changed

Diff for: consumer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ ZEND_METHOD(SimpleKafkaClient_Consumer, unsubscribe)
339339
}
340340
/* }}} */
341341

342-
/* {{{ proto Message SimpleKafkaClient\Consumer::consume()
342+
/* {{{ proto Message SimpleKafkaClient\Consumer::consume(int $timeoutMs)
343343
Consume message or get error event, triggers callbacks */
344344
ZEND_METHOD(SimpleKafkaClient_Consumer, consume)
345345
{

Diff for: consumer.stub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Consumer
88
{
99
public function __construct(Configuration $configuration) {}
1010

11-
public function assign(array $topics): void {}
11+
public function assign(?array $topics): void {}
1212

1313
public function getAssignment(): array {}
1414

Diff for: consumer_arginfo.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: b42d1bb68767786f0b655714b388a3361a45551d */
2+
* Stub hash: ba3bc0a741bc6eab7a23a15ca6d83c24e99b23de */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SimpleKafkaClient_Consumer___construct, 0, 0, 1)
55
ZEND_ARG_OBJ_INFO(0, configuration, SimpleKafkaClient\\Configuration, 0)
66
ZEND_END_ARG_INFO()
77

88
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SimpleKafkaClient_Consumer_assign, 0, 1, IS_VOID, 0)
9-
ZEND_ARG_TYPE_INFO(0, topics, IS_ARRAY, 0)
9+
ZEND_ARG_TYPE_INFO(0, topics, IS_ARRAY, 1)
1010
ZEND_END_ARG_INFO()
1111

1212
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SimpleKafkaClient_Consumer_getAssignment, 0, 0, IS_ARRAY, 0)
1313
ZEND_END_ARG_INFO()
1414

15-
#define arginfo_class_SimpleKafkaClient_Consumer_subscribe arginfo_class_SimpleKafkaClient_Consumer_assign
15+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SimpleKafkaClient_Consumer_subscribe, 0, 1, IS_VOID, 0)
16+
ZEND_ARG_TYPE_INFO(0, topics, IS_ARRAY, 0)
17+
ZEND_END_ARG_INFO()
1618

1719
#define arginfo_class_SimpleKafkaClient_Consumer_getSubscription arginfo_class_SimpleKafkaClient_Consumer_getAssignment
1820

Diff for: kafka.stub.php

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ abstract class Kafka
88
{
99
public function getMetadata(bool $allTopics, int $timeoutMs, Topic $topic): Metadata {}
1010

11-
public function getTopicHandle(string $topic): Topic {}
12-
1311
public function getOutQLen(): int {}
1412

1513
public function poll(int $timeoutMs): int {}

Diff for: kafka_arginfo.h

-6
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_SimpleKafkaClient_SimpleKaf
77
ZEND_ARG_OBJ_INFO(0, topic, SimpleKafkaClient\\Topic, 0)
88
ZEND_END_ARG_INFO()
99

10-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_SimpleKafkaClient_SimpleKafkaClient_getTopicHandle, 0, 1, SimpleKafkaClient\\Topic, 0)
11-
ZEND_ARG_TYPE_INFO(0, topic, IS_STRING, 0)
12-
ZEND_END_ARG_INFO()
13-
1410
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SimpleKafkaClient_SimpleKafkaClient_getOutQLen, 0, 0, IS_LONG, 0)
1511
ZEND_END_ARG_INFO()
1612

@@ -33,7 +29,6 @@ ZEND_END_ARG_INFO()
3329

3430

3531
ZEND_METHOD(SimpleKafkaClient_Kafka, getMetadata);
36-
ZEND_METHOD(SimpleKafkaClient_Kafka, getTopicHandle);
3732
ZEND_METHOD(SimpleKafkaClient_Kafka, getOutQLen);
3833
ZEND_METHOD(SimpleKafkaClient_Kafka, poll);
3934
ZEND_METHOD(SimpleKafkaClient_Kafka, queryWatermarkOffsets);
@@ -42,7 +37,6 @@ ZEND_METHOD(SimpleKafkaClient_Kafka, offsetsForTimes);
4237

4338
static const zend_function_entry class_SimpleKafkaClient_SimpleKafkaClient_methods[] = {
4439
ZEND_ME(SimpleKafkaClient_Kafka, getMetadata, arginfo_class_SimpleKafkaClient_SimpleKafkaClient_getMetadata, ZEND_ACC_PUBLIC)
45-
ZEND_ME(SimpleKafkaClient_Kafka, getTopicHandle, arginfo_class_SimpleKafkaClient_SimpleKafkaClient_getTopicHandle, ZEND_ACC_PUBLIC)
4640
ZEND_ME(SimpleKafkaClient_Kafka, getOutQLen, arginfo_class_SimpleKafkaClient_SimpleKafkaClient_getOutQLen, ZEND_ACC_PUBLIC)
4741
ZEND_ME(SimpleKafkaClient_Kafka, poll, arginfo_class_SimpleKafkaClient_SimpleKafkaClient_poll, ZEND_ACC_PUBLIC)
4842
ZEND_ME(SimpleKafkaClient_Kafka, queryWatermarkOffsets, arginfo_class_SimpleKafkaClient_SimpleKafkaClient_queryWatermarkOffsets, ZEND_ACC_PUBLIC)

Diff for: producer.c

+44
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,50 @@ ZEND_METHOD(SimpleKafkaClient_Producer, purge)
140140
}
141141
/* }}} */
142142

143+
144+
/* {{{ proto SimpleKafkaClient\ProducerTopic SimpleKafkaClient\Producer::getTopicHandle(string $topic)
145+
Returns an SimpleKafkaClient\ProducerTopic object */
146+
ZEND_METHOD(SimpleKafkaClient_Producer, getTopicHandle)
147+
{
148+
char *topic;
149+
size_t topic_len;
150+
rd_kafka_topic_t *rkt;
151+
kafka_object *intern;
152+
kafka_topic_object *topic_intern;
153+
154+
ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1)
155+
Z_PARAM_STRING(topic, topic_len)
156+
ZEND_PARSE_PARAMETERS_END();
157+
158+
intern = get_kafka_object(getThis());
159+
if (!intern) {
160+
return;
161+
}
162+
163+
rkt = rd_kafka_topic_new(intern->rk, topic, NULL);
164+
165+
if (!rkt) {
166+
return;
167+
}
168+
169+
if (object_init_ex(return_value, ce_kafka_producer_topic) != SUCCESS) {
170+
return;
171+
}
172+
173+
topic_intern = Z_KAFKA_P(kafka_topic_object, return_value);
174+
if (!topic_intern) {
175+
return;
176+
}
177+
178+
topic_intern->rkt = rkt;
179+
topic_intern->zrk = *getThis();
180+
181+
Z_ADDREF_P(&topic_intern->zrk);
182+
183+
zend_hash_index_add_ptr(&intern->topics, (zend_ulong)topic_intern, topic_intern);
184+
}
185+
/* }}} */
186+
143187
/* {{{ proto int SimpleKafkaClient\Producer::initTransactions(int timeout_ms)
144188
Initializes transactions, needs to be done before producing and starting a transaction */
145189
ZEND_METHOD(SimpleKafkaClient_Producer, initTransactions)

Diff for: producer.stub.php

+2
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ public function abortTransaction(int $timeoutMs): void {}
1919
public function flush(int $timeoutMs): int {}
2020

2121
public function purge(int $purgeFlags): int {}
22+
23+
public function getTopicHandle(string $topic): ProducerTopic {}
2224
}

Diff for: producer_arginfo.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: b31742490463035fecff0a1cee01effed6e3e1d6 */
2+
* Stub hash: ae03dd8127a9e4799e241bc490de200ff18a4178 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SimpleKafkaClient_Producer___construct, 0, 0, 1)
55
ZEND_ARG_OBJ_INFO(0, configuration, SimpleKafkaClient\\Configuration, 0)
@@ -24,6 +24,10 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SimpleKafkaClient_Producer
2424
ZEND_ARG_TYPE_INFO(0, purgeFlags, IS_LONG, 0)
2525
ZEND_END_ARG_INFO()
2626

27+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_SimpleKafkaClient_Producer_getTopicHandle, 0, 1, SimpleKafkaClient\\ProducerTopic, 0)
28+
ZEND_ARG_TYPE_INFO(0, topic, IS_STRING, 0)
29+
ZEND_END_ARG_INFO()
30+
2731

2832
ZEND_METHOD(SimpleKafkaClient_Producer, __construct);
2933
ZEND_METHOD(SimpleKafkaClient_Producer, initTransactions);
@@ -32,6 +36,7 @@ ZEND_METHOD(SimpleKafkaClient_Producer, commitTransaction);
3236
ZEND_METHOD(SimpleKafkaClient_Producer, abortTransaction);
3337
ZEND_METHOD(SimpleKafkaClient_Producer, flush);
3438
ZEND_METHOD(SimpleKafkaClient_Producer, purge);
39+
ZEND_METHOD(SimpleKafkaClient_Producer, getTopicHandle);
3540

3641

3742
static const zend_function_entry class_SimpleKafkaClient_Producer_methods[] = {
@@ -42,5 +47,6 @@ static const zend_function_entry class_SimpleKafkaClient_Producer_methods[] = {
4247
ZEND_ME(SimpleKafkaClient_Producer, abortTransaction, arginfo_class_SimpleKafkaClient_Producer_abortTransaction, ZEND_ACC_PUBLIC)
4348
ZEND_ME(SimpleKafkaClient_Producer, flush, arginfo_class_SimpleKafkaClient_Producer_flush, ZEND_ACC_PUBLIC)
4449
ZEND_ME(SimpleKafkaClient_Producer, purge, arginfo_class_SimpleKafkaClient_Producer_purge, ZEND_ACC_PUBLIC)
50+
ZEND_ME(SimpleKafkaClient_Producer, getTopicHandle, arginfo_class_SimpleKafkaClient_Producer_getTopicHandle, ZEND_ACC_PUBLIC)
4551
ZEND_FE_END
4652
};

Diff for: simple_kafka_client.c

-43
Original file line numberDiff line numberDiff line change
@@ -155,49 +155,6 @@ ZEND_METHOD(SimpleKafkaClient_Kafka, getMetadata)
155155
}
156156
/* }}} */
157157

158-
/* {{{ proto SimpleKafkaClient\Topic SimpleKafkaClient\Kafka::getTopicHandle(string $topic)
159-
Returns an SimpleKafkaClient\Topic object */
160-
ZEND_METHOD(SimpleKafkaClient_Kafka, getTopicHandle)
161-
{
162-
char *topic;
163-
size_t topic_len;
164-
rd_kafka_topic_t *rkt;
165-
kafka_object *intern;
166-
kafka_topic_object *topic_intern;
167-
168-
ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1, 1)
169-
Z_PARAM_STRING(topic, topic_len)
170-
ZEND_PARSE_PARAMETERS_END();
171-
172-
intern = get_kafka_object(getThis());
173-
if (!intern) {
174-
return;
175-
}
176-
177-
rkt = rd_kafka_topic_new(intern->rk, topic, NULL);
178-
179-
if (!rkt) {
180-
return;
181-
}
182-
183-
if (object_init_ex(return_value, ce_kafka_producer_topic) != SUCCESS) {
184-
return;
185-
}
186-
187-
topic_intern = Z_KAFKA_P(kafka_topic_object, return_value);
188-
if (!topic_intern) {
189-
return;
190-
}
191-
192-
topic_intern->rkt = rkt;
193-
topic_intern->zrk = *getThis();
194-
195-
Z_ADDREF_P(&topic_intern->zrk);
196-
197-
zend_hash_index_add_ptr(&intern->topics, (zend_ulong)topic_intern, topic_intern);
198-
}
199-
/* }}} */
200-
201158
/* {{{ proto int SimpleKafkaClient\Kafka::getOutQLen()
202159
Returns the current out queue length */
203160
ZEND_METHOD(SimpleKafkaClient_Kafka, getOutQLen)

0 commit comments

Comments
 (0)