diff --git a/.gitignore b/.gitignore index 03da8d9..c198adb 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,6 @@ ltmain.sh missing mkinstalldirs modules -package.xml kafka-*.tgz run-tests.php tests/*/*.diff diff --git a/configuration.c b/configuration.c index 09fce46..d784077 100644 --- a/configuration.c +++ b/configuration.c @@ -5,11 +5,8 @@ #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "Zend/zend_exceptions.h" -#include "ext/spl/spl_exceptions.h" #include "configuration_arginfo.h" zend_class_entry * ce_kafka_conf; diff --git a/configuration.h b/configuration.h deleted file mode 100644 index 53bc607..0000000 --- a/configuration.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef KAFKA_CONF_H -#define KAFKA_CONF_H - - - - - -#endif /* KAFKA_CONF_H */ diff --git a/consumer.c b/consumer.c index 858fc36..148ad6e 100644 --- a/consumer.c +++ b/consumer.c @@ -3,9 +3,7 @@ #endif #include "php.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "Zend/zend_exceptions.h" #include "consumer_arginfo.h" diff --git a/functions.c b/functions.c index e78402f..e34611e 100644 --- a/functions.c +++ b/functions.c @@ -3,11 +3,8 @@ #endif #include "php.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "Zend/zend_exceptions.h" -#include "ext/spl/spl_exceptions.h" #include "functions_arginfo.h" /* {{{ proto array kafka_get_err_descs() diff --git a/kafka.c b/kafka.c index c88f1e8..6a8af61 100644 --- a/kafka.c +++ b/kafka.c @@ -7,11 +7,8 @@ #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" -#include "librdkafka/rdkafka.h" -#include "php_kafka.h" #include "php_kafka_int.h" #include "Zend/zend_exceptions.h" -#include "ext/spl/spl_exceptions.h" #include "functions_arginfo.h" #include "producer_arginfo.h" #include "kafka_arginfo.h" diff --git a/kafka_exception.c b/kafka_exception.c index cbeafbc..ae9892f 100644 --- a/kafka_exception.c +++ b/kafka_exception.c @@ -3,7 +3,6 @@ #endif #include "php.h" -#include "php_kafka.h" #include "php_kafka_int.h" #include "Zend/zend_interfaces.h" #include "Zend/zend_exceptions.h" diff --git a/message.c b/message.c index 20bc8f2..2b52221 100644 --- a/message.c +++ b/message.c @@ -3,9 +3,7 @@ #endif #include "php.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "ext/spl/spl_iterators.h" #include "Zend/zend_interfaces.h" #include "Zend/zend_exceptions.h" diff --git a/metadata.c b/metadata.c index fc52074..e5aee78 100644 --- a/metadata.c +++ b/metadata.c @@ -3,9 +3,7 @@ #endif #include "php.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "Zend/zend_exceptions.h" #include "metadata_arginfo.h" diff --git a/metadata_broker.c b/metadata_broker.c index 14a3925..37bbec1 100644 --- a/metadata_broker.c +++ b/metadata_broker.c @@ -3,9 +3,7 @@ #endif #include "php.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "ext/spl/spl_iterators.h" #include "Zend/zend_interfaces.h" #include "Zend/zend_exceptions.h" diff --git a/metadata_collection.c b/metadata_collection.c index d0a0969..7bf8f55 100644 --- a/metadata_collection.c +++ b/metadata_collection.c @@ -3,9 +3,7 @@ #endif #include "php.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "ext/spl/spl_iterators.h" #include "Zend/zend_interfaces.h" #include "metadata_collection_arginfo.h" diff --git a/metadata_partition.c b/metadata_partition.c index 9c9f792..f6c3546 100644 --- a/metadata_partition.c +++ b/metadata_partition.c @@ -3,9 +3,7 @@ #endif #include "php.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "ext/spl/spl_iterators.h" #include "Zend/zend_interfaces.h" #include "Zend/zend_exceptions.h" diff --git a/metadata_topic.c b/metadata_topic.c index e084a47..8a0ba1c 100644 --- a/metadata_topic.c +++ b/metadata_topic.c @@ -3,9 +3,7 @@ #endif #include "php.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "ext/spl/spl_iterators.h" #include "Zend/zend_interfaces.h" #include "Zend/zend_exceptions.h" diff --git a/package.xml b/package.xml new file mode 100644 index 0000000..ff065d8 --- /dev/null +++ b/package.xml @@ -0,0 +1,93 @@ + + + kafka + pecl.php.net + Kafka client based on librdkafka + This extension is a librdkafka binding providing a working client for Kafka + + Nick Chiu + nick-zh + nick@probiers.us + yes + + 2020-12-06 + + + 1.0.0 + 1.0.0 + + + stable + stable + + BSD-3 License + + Initial release + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 7.3.0 + 8.99.99 + + + 1.4.8 + + + + kafka + + + + diff --git a/php_kafka.h b/php_kafka.h deleted file mode 100644 index 465a28a..0000000 --- a/php_kafka.h +++ /dev/null @@ -1,42 +0,0 @@ -/* $Id$ */ - -#ifndef PHP_KAFKA_H -#define PHP_KAFKA_H - -#include "librdkafka/rdkafka.h" -#include "php_kafka_int.h" - -#ifndef ZEND_FE_END -#define ZEND_FE_END { NULL, NULL, NULL, 0, 0 } -#endif - -typedef struct _kafka_object { - rd_kafka_type_t type; - rd_kafka_t *rk; - kafka_conf_callbacks cbs; - HashTable consuming; - HashTable topics; - HashTable queues; - zend_object std; -} kafka_object; - -ZEND_METHOD(Kafka, __construct); - -extern zend_module_entry kafka_module_entry; -#define phpext_kafka_ptr &kafka_module_entry - -#define PHP_KAFKA_VERSION "1.0.0" - -extern zend_object_handlers kafka_default_object_handlers; - -#ifdef PHP_WIN32 -# define PHP_KAFKA_API __declspec(dllexport) -#elif defined(__GNUC__) && __GNUC__ >= 4 -# define PHP_KAFKA_API __attribute__ ((visibility("default"))) -#else -# define PHP_KAFKA_API -#endif - -kafka_object * get_kafka_object(zval *zrk); - -#endif /* PHP_KAFKA_H */ diff --git a/php_kafka_int.h b/php_kafka_int.h index 1f5e70d..48daec7 100644 --- a/php_kafka_int.h +++ b/php_kafka_int.h @@ -1,6 +1,8 @@ #ifndef PHP_KAFKA_INT_H #define PHP_KAFKA_INT_H +#include "librdkafka/rdkafka.h" + typedef struct _kafka_topic_object { rd_kafka_topic_t *rkt; zval zrk; @@ -36,6 +38,16 @@ typedef struct _kafka_topic_partition_intern { zend_object std; } kafka_topic_partition_intern; +typedef struct _kafka_object { + rd_kafka_type_t type; + rd_kafka_t *rk; + kafka_conf_callbacks cbs; + HashTable consuming; + HashTable topics; + HashTable queues; + zend_object std; +} kafka_object; + typedef void (*kafka_metadata_collection_ctor_t)(zval *renurn_value, zval *zmetadata, const void *object); @@ -59,6 +71,14 @@ typedef void (*kafka_metadata_collection_ctor_t)(zval *renurn_value, zval *zmeta #endif +#ifdef PHP_WIN32 +# define PHP_KAFKA_API __declspec(dllexport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +# define PHP_KAFKA_API __attribute__ ((visibility("default"))) +#else +# define PHP_KAFKA_API +#endif + extern zend_class_entry * ce_kafka_conf; extern zend_class_entry * ce_kafka_error_exception; extern zend_class_entry * ce_kafka_exception; @@ -68,12 +88,19 @@ extern zend_class_entry * ce_kafka_consumer_topic; extern zend_class_entry * ce_kafka_producer_topic; extern zend_class_entry * ce_kafka_topic; extern zend_class_entry * ce_kafka_topic_partition; +extern zend_module_entry kafka_module_entry; +extern zend_object_handlers kafka_default_object_handlers; #define Z_KAFKA_P(php_kafka_type, zobject) php_kafka_from_obj(php_kafka_type, Z_OBJ_P(zobject)) #define php_kafka_from_obj(php_kafka_type, object) \ ((php_kafka_type*)((char *)(object) - XtOffsetOf(php_kafka_type, std))) +#define phpext_kafka_ptr &kafka_module_entry + +#define PHP_KAFKA_VERSION "1.0.0" + + static inline void kafka_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache, zval *retval, uint32_t param_count, zval params[]) { int local_retval; @@ -144,5 +171,8 @@ kafka_topic_partition_intern * get_topic_partition_object(zval *z); rd_kafka_topic_partition_list_t * array_arg_to_kafka_topic_partition_list(int argnum, HashTable *ary); kafka_topic_object * get_kafka_topic_object(zval *zrkt); kafka_conf_object * get_kafka_conf_object(zval *zconf); +kafka_object * get_kafka_object(zval *zrk); + +ZEND_METHOD(Kafka, __construct); #endif /* PHP_KAFKA_INT_H */ diff --git a/producer.c b/producer.c index 60b9734..dce7f8c 100644 --- a/producer.c +++ b/producer.c @@ -3,8 +3,6 @@ #endif #include "php.h" -#include "php_kafka.h" -#include "librdkafka/rdkafka.h" #include "php_kafka_int.h" #include "Zend/zend_exceptions.h" #include "producer_arginfo.h" diff --git a/topic.c b/topic.c index 0cba442..5de3886 100644 --- a/topic.c +++ b/topic.c @@ -3,9 +3,7 @@ #endif #include "php.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "ext/spl/spl_iterators.h" #include "Zend/zend_interfaces.h" #include "Zend/zend_exceptions.h" diff --git a/topic_partition.c b/topic_partition.c index 2f71a6c..c32952f 100644 --- a/topic_partition.c +++ b/topic_partition.c @@ -5,11 +5,8 @@ #include "php.h" #include "php_ini.h" #include "ext/standard/info.h" -#include "php_kafka.h" #include "php_kafka_int.h" -#include "librdkafka/rdkafka.h" #include "Zend/zend_exceptions.h" -#include "ext/spl/spl_exceptions.h" #include "topic_partition_arginfo.h" typedef kafka_topic_partition_intern object_intern;