Skip to content

Commit

Permalink
feat: exclude setOauthbearerTokenRefreshCb method pre librdkafka 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-freddysart committed Jan 4, 2024
1 parent d2ebbd5 commit 628ba23
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
7 changes: 2 additions & 5 deletions conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,15 +734,11 @@ PHP_METHOD(RdKafka_Conf, setLogCb)
}
/* }}} */

#ifdef HAS_RD_KAFKA_OAUTHBEARER_TOKEN_REFRESH_CB
/* {{{ proto void RdKafka\Conf::setOauthbearerTokenRefreshCb(mixed $callback)
Set token refresh callback for OAUTHBEARER sasl */
PHP_METHOD(RdKafka_Conf, setOauthbearerTokenRefreshCb)
{
#ifndef HAS_RD_KAFKA_OAUTHBEARER_TOKEN_REFRESH_CB
zend_throw_exception_ex(NULL, 0, "This version of rdkafka does not support the OAUTHBEARER sasl mechanism");
return;
#endif

zend_fcall_info fci;
zend_fcall_info_cache fcc;
kafka_conf_object *conf;
Expand Down Expand Up @@ -770,6 +766,7 @@ PHP_METHOD(RdKafka_Conf, setOauthbearerTokenRefreshCb)
rd_kafka_conf_set_oauthbearer_token_refresh_cb(conf->u.conf, kafka_conf_set_oauthbearer_token_refresh_cb);
}
/* }}} */
#endif

/* {{{ proto RdKafka\TopicConf::__construct() */
PHP_METHOD(RdKafka_TopicConf, __construct)
Expand Down
2 changes: 2 additions & 0 deletions conf.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ public function setOffsetCommitCb(callable $callback): void {}
/** @tentative-return-type */
public function setLogCb(callable $callback): void {}

#ifdef HAS_RD_KAFKA_OAUTHBEARER_TOKEN_REFRESH_CB
/** @tentative-return-type */
public function setOauthbearerTokenRefreshCb(callable $callback): void {}
#endif
}

class TopicConf
Expand Down
12 changes: 4 additions & 8 deletions tests/conf_callbacks.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ $conf->setRebalanceCb(function () { });
$dump = $conf->dump();
var_dump(isset($dump["rebalance_cb"]));

echo "Setting oauth token bearer callback\n";
try {
$conf->setOauthbearerTokenRefreshCb(function () {});
} catch (\Exception $e) {
echo $e->getMessage()."\n";
}
echo "Checking if oauthbearer cb exists\n";
var_dump(method_exists($conf, 'setOauthbearerTokenRefreshCb'));

--EXPECT--
Setting consume callback
Expand All @@ -37,5 +33,5 @@ Setting offset_commit callback
bool(true)
Setting rebalance callback
bool(true)
Setting oauth token bearer callback
This version of rdkafka does not support the OAUTHBEARER sasl mechanism
Checking if oauthbearer cb exists
bool(false)

0 comments on commit 628ba23

Please sign in to comment.