1 /*
2   +----------------------------------------------------------------------+
3   | php-rdkafka                                                          |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 2016 Arnaud Le Blanc                                   |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author: Arnaud Le Blanc <arnaud.lb@gmail.com>                        |
16   +----------------------------------------------------------------------+
17 */
18 
19 #ifndef KAFKA_CONF_H
20 #define KAFKA_CONF_H
21 
22 enum {
23         MSG_PARTITIONER_RANDOM = 2,
24         MSG_PARTITIONER_CONSISTENT = 3,
25         MSG_PARTITIONER_CONSISTENT_RANDOM = 4,
26         MSG_PARTITIONER_MURMUR2 = 5,
27         MSG_PARTITIONER_MURMUR2_RANDOM = 6
28 };
29 
30 typedef enum {
31     KAFKA_CONF = 1,
32     KAFKA_TOPIC_CONF
33 } kafka_conf_type;
34 
35 typedef struct _kafka_conf_callback {
36     zend_fcall_info fci;
37     zend_fcall_info_cache fcc;
38 } kafka_conf_callback;
39 
40 typedef struct _kafka_conf_callbacks {
41     zval zrk;
42     kafka_conf_callback *error;
43     kafka_conf_callback *rebalance;
44     kafka_conf_callback *dr_msg;
45     kafka_conf_callback *stats;
46     kafka_conf_callback *consume;
47     kafka_conf_callback *offset_commit;
48     kafka_conf_callback *log;
49 } kafka_conf_callbacks;
50 
51 typedef struct _kafka_conf_object {
52 #if PHP_MAJOR_VERSION < 7
53     zend_object                 std;
54 #endif
55     kafka_conf_type type;
56     union {
57         rd_kafka_conf_t         *conf;
58         rd_kafka_topic_conf_t   *topic_conf;
59     } u;
60     kafka_conf_callbacks cbs;
61 #if PHP_MAJOR_VERSION >= 7
62     zend_object                 std;
63 #endif
64 } kafka_conf_object;
65 
66 kafka_conf_object * get_kafka_conf_object(zval *zconf TSRMLS_DC);
67 void kafka_conf_minit(TSRMLS_D);
68 
69 void kafka_conf_callbacks_dtor(kafka_conf_callbacks *cbs TSRMLS_DC);
70 void kafka_conf_callbacks_copy(kafka_conf_callbacks *to, kafka_conf_callbacks *from TSRMLS_DC);
71 
72 extern zend_class_entry * ce_kafka_conf;
73 extern zend_class_entry * ce_kafka_topic_conf;
74 
75 #endif /* KAFKA_CONF_H */
76