@@ -66,6 +66,8 @@ void kafka_conf_callbacks_dtor(kafka_conf_callbacks *cbs) /* {{{ */
6666 cbs -> offset_commit = NULL ;
6767 kafka_conf_callback_dtor (cbs -> log );
6868 cbs -> log = NULL ;
69+ kafka_conf_callback_dtor (cbs -> oauthbearer_token_refresh );
70+ cbs -> oauthbearer_token_refresh = NULL ;
6971} /* }}} */
7072
7173static void kafka_conf_callback_copy (kafka_conf_callback * * to , kafka_conf_callback * from ) /* {{{ */
@@ -337,6 +339,40 @@ static void kafka_conf_log_cb(const rd_kafka_t *rk, int level, const char *facil
337339 zval_ptr_dtor (& args [3 ]);
338340}
339341
342+ /*
343+ void rd_kafka_conf_set_oauthbearer_token_refresh_cb(
344+ rd_kafka_conf_t *conf,
345+ void (*oauthbearer_token_refresh_cb)(rd_kafka_t *rk,
346+ const char *oauthbearer_config,
347+ void *opaque)) {
348+ }*/
349+ static void kafka_conf_set_oauthbearer_token_refresh_cb (rd_kafka_t * rk , const char * oauthbearer_config , void * opaque )
350+ {
351+ kafka_conf_callbacks * cbs = (kafka_conf_callbacks * ) opaque ;
352+ zval args [2 ];
353+
354+ if (!opaque ) {
355+ return ;
356+ }
357+
358+ if (!cbs -> oauthbearer_token_refresh ) {
359+ return ;
360+ }
361+
362+ ZVAL_NULL (& args [0 ]);
363+ ZVAL_NULL (& args [1 ]);
364+
365+ ZVAL_ZVAL (& args [0 ], & cbs -> zrk , 1 , 0 );
366+ ZVAL_STRING (& args [1 ], oauthbearer_config );
367+
368+ rdkafka_call_function (& cbs -> oauthbearer_token_refresh -> fci , & cbs -> oauthbearer_token_refresh -> fcc , NULL , 2 , args );
369+
370+ zval_ptr_dtor (& args [0 ]);
371+ zval_ptr_dtor (& args [1 ]);
372+ }
373+
374+
375+
340376/* {{{ proto RdKafka\Conf::__construct() */
341377PHP_METHOD (RdKafka_Conf , __construct )
342378{
@@ -698,6 +734,40 @@ PHP_METHOD(RdKafka_Conf, setLogCb)
698734}
699735/* }}} */
700736
737+ #ifdef HAS_RD_KAFKA_OAUTHBEARER_TOKEN_REFRESH_CB
738+ /* {{{ proto void RdKafka\Conf::setOauthbearerTokenRefreshCb(mixed $callback)
739+ Set token refresh callback for OAUTHBEARER sasl */
740+ PHP_METHOD (RdKafka_Conf , setOauthbearerTokenRefreshCb )
741+ {
742+ zend_fcall_info fci ;
743+ zend_fcall_info_cache fcc ;
744+ kafka_conf_object * conf ;
745+
746+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "f" , & fci , & fcc ) == FAILURE ) {
747+ return ;
748+ }
749+
750+ conf = get_kafka_conf_object (getThis ());
751+ if (!conf ) {
752+ return ;
753+ }
754+
755+ Z_ADDREF_P (& fci .function_name );
756+
757+ if (conf -> cbs .oauthbearer_token_refresh ) {
758+ zval_ptr_dtor (& conf -> cbs .oauthbearer_token_refresh -> fci .function_name );
759+ } else {
760+ conf -> cbs .oauthbearer_token_refresh = ecalloc (1 , sizeof (* conf -> cbs .oauthbearer_token_refresh ));
761+ }
762+
763+ conf -> cbs .oauthbearer_token_refresh -> fci = fci ;
764+ conf -> cbs .oauthbearer_token_refresh -> fcc = fcc ;
765+
766+ rd_kafka_conf_set_oauthbearer_token_refresh_cb (conf -> u .conf , kafka_conf_set_oauthbearer_token_refresh_cb );
767+ }
768+ /* }}} */
769+ #endif
770+
701771/* {{{ proto RdKafka\TopicConf::__construct() */
702772PHP_METHOD (RdKafka_TopicConf , __construct )
703773{
0 commit comments