Skip to content

Commit

Permalink
add method to check rebalance protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
olegrok committed Jun 13, 2024
1 parent 97bd101 commit a87d2e5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions kafka/consumer.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,3 +821,17 @@ int
lua_consumer_resume(struct lua_State *L) {
return lua_consumer_call_pause_resume(L, kafka_resume);
}

int
lua_consumer_rebalance_protocol(struct lua_State *L) {
consumer_t **consumer_p = luaL_checkudata(L, 1, consumer_label);
if (consumer_p == NULL || *consumer_p == NULL)
return 0;

if ((*consumer_p)->rd_consumer != NULL) {
const char *proto = rd_kafka_rebalance_protocol((*consumer_p)->rd_consumer);
lua_pushstring(L, proto);
return 1;
}
return 0;
}
3 changes: 3 additions & 0 deletions kafka/consumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@ lua_consumer_pause(struct lua_State *L);
int
lua_consumer_resume(struct lua_State *L);

int
lua_consumer_rebalance_protocol(struct lua_State *L);

#endif //TNT_KAFKA_CONSUMER_H
4 changes: 4 additions & 0 deletions kafka/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ function Consumer:resume()
return self._consumer:resume()
end

function Consumer:rebalance_protocol()
return self._consumer:rebalance_protocol()
end

function Consumer:seek_partitions(topic_partitions_list, options)
local timeout_ms = get_timeout_from_options(options)
return self._consumer:seek_partitions(topic_partitions_list, timeout_ms)
Expand Down
1 change: 1 addition & 0 deletions kafka/tnt_kafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ luaopen_kafka_tntkafka(lua_State *L) {
{"resume", lua_consumer_resume},
{"close", lua_consumer_close},
{"destroy", lua_consumer_destroy},
{"rebalance_protocol", lua_consumer_rebalance_protocol},
{"__tostring", lua_consumer_tostring},
{NULL, NULL}
};
Expand Down

0 comments on commit a87d2e5

Please sign in to comment.