Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 108 additions & 2 deletions src/confluent_kafka/src/Admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Admin_options_to_c (Handle *self, rd_kafka_admin_op_t for_api,
char errstr[512];

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, "AdminClient has been closed");
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
return NULL;
}

Expand Down Expand Up @@ -578,6 +578,11 @@ static PyObject *Admin_create_topics (Handle *self, PyObject *args,
&options.validate_only))
return NULL;

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
return NULL;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_CREATETOPICS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -721,6 +726,11 @@ static PyObject *Admin_delete_topics (Handle *self, PyObject *args,
return NULL;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
return NULL;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_DELETETOPICS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -831,6 +841,11 @@ static PyObject *Admin_create_partitions (Handle *self, PyObject *args,
&options.validate_only))
return NULL;

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
return NULL;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_CREATEPARTITIONS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -952,6 +967,11 @@ static PyObject *Admin_describe_configs (Handle *self, PyObject *args,
return NULL;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
return NULL;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_DESCRIBECONFIGS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -1085,6 +1105,12 @@ static PyObject *Admin_incremental_alter_configs(Handle *self,PyObject *args,PyO
!cfl_PyBool_get(validate_only_obj, "validate_only",
&options.validate_only))
return NULL;

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
return NULL;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_INCREMENTALALTERCONFIGS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -1252,6 +1278,11 @@ static PyObject *Admin_alter_configs (Handle *self, PyObject *args,
&options.validate_only))
return NULL;

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
return NULL;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_ALTERCONFIGS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -1409,6 +1440,11 @@ static PyObject *Admin_create_acls (Handle *self, PyObject *args, PyObject *kwar
goto err;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_CREATEACLS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -1528,6 +1564,11 @@ static PyObject *Admin_describe_acls (Handle *self, PyObject *args, PyObject *kw
goto err;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_CREATEACLS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -1640,6 +1681,11 @@ static PyObject *Admin_delete_acls (Handle *self, PyObject *args, PyObject *kwar
goto err;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_DELETEACLS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -1804,6 +1850,11 @@ PyObject *Admin_list_consumer_groups (Handle *self, PyObject *args, PyObject *kw
}
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_LISTCONSUMERGROUPS,
&options, future);
if (!c_options) {
Expand Down Expand Up @@ -1890,6 +1941,11 @@ static PyObject *Admin_describe_user_scram_credentials(Handle *self, PyObject *a
return NULL;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
return NULL;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_DESCRIBEUSERSCRAMCREDENTIALS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -2054,6 +2110,11 @@ static PyObject *Admin_alter_user_scram_credentials(Handle *self, PyObject *args
goto err;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_ALTERUSERSCRAMCREDENTIALS,
&options, future);
if (!c_options)
Expand Down Expand Up @@ -2303,6 +2364,11 @@ PyObject *Admin_describe_consumer_groups (Handle *self, PyObject *args, PyObject
Py_XDECREF(uogroup);
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_DESCRIBECONSUMERGROUPS,
&options, future);
if (!c_options) {
Expand Down Expand Up @@ -2426,6 +2492,11 @@ PyObject *Admin_describe_topics (Handle *self, PyObject *args, PyObject *kwargs)
}
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_topic_collection = rd_kafka_TopicCollection_of_topic_names(c_topics, topics_cnt);
c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_DESCRIBETOPICS,
&options, future);
Expand Down Expand Up @@ -2514,6 +2585,11 @@ PyObject *Admin_describe_cluster (Handle *self, PyObject *args, PyObject *kwargs
&options.include_authorized_operations))
goto err;

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_DESCRIBECLUSTER,
&options, future);
if (!c_options) {
Expand Down Expand Up @@ -2586,6 +2662,11 @@ PyObject *Admin_delete_consumer_groups (Handle *self, PyObject *args, PyObject *
goto err;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_DELETEGROUPS,
&options, future);
if (!c_options) {
Expand Down Expand Up @@ -2702,6 +2783,11 @@ PyObject *Admin_list_consumer_group_offsets (Handle *self, PyObject *args, PyObj
&options.require_stable_offsets))
return NULL;

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_LISTCONSUMERGROUPOFFSETS,
&options, future);
if (!c_options) {
Expand Down Expand Up @@ -2841,6 +2927,11 @@ PyObject *Admin_alter_consumer_group_offsets (Handle *self, PyObject *args, PyOb
goto err;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_ALTERCONSUMERGROUPOFFSETS,
&options, future);
if (!c_options) {
Expand Down Expand Up @@ -2972,6 +3063,11 @@ PyObject *Admin_list_offsets (Handle *self,PyObject *args, PyObject *kwargs) {
goto err;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_LISTOFFSETS,
&options, future);
if (!c_options) {
Expand Down Expand Up @@ -3054,6 +3150,11 @@ PyObject* Admin_delete_records (Handle *self,PyObject *args,PyObject *kwargs){
goto err;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_DELETERECORDS,
&options, future);
if (!c_options) {
Expand Down Expand Up @@ -3148,6 +3249,11 @@ PyObject *Admin_elect_leaders(Handle *self, PyObject *args, PyObject *kwargs) {
goto err;
}

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
goto err;
}

c_options = Admin_options_to_c(self, RD_KAFKA_ADMIN_OP_ELECTLEADERS,
&options, future);
if (!c_options) {
Expand Down Expand Up @@ -3251,7 +3357,7 @@ static PyObject *Admin_poll (Handle *self, PyObject *args,
return NULL;

if (!self->rk) {
PyErr_SetString(PyExc_RuntimeError, "AdminClient has been closed");
PyErr_SetString(PyExc_RuntimeError, ERR_MSG_ADMIN_CLIENT_CLOSED);
return NULL;
}

Expand Down
Loading