Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannguyen4 committed Sep 10, 2024
1 parent 9108e72 commit 9ce9f15
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
11 changes: 8 additions & 3 deletions src/main/aerospike.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,14 @@ PyMODINIT_FUNC PyInit_aerospike(void)
}
}

// TODO: leave off from here
declare_policy_constants(py_aerospike_module);
declare_log_constants(py_aerospike_module);
retval = declare_policy_constants(py_aerospike_module);
if (retval == -1) {
goto GLOBAL_HOSTS_CLEANUP;
}
retval = declare_log_constants(py_aerospike_module);
if (retval == -1) {
goto GLOBAL_HOSTS_CLEANUP;
}

return py_aerospike_module;

Expand Down
16 changes: 3 additions & 13 deletions src/main/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,17 @@ static AerospikeLogCallback user_callback;
/*
* Declare's log level constants.
*/
as_status declare_log_constants(PyObject *aerospike)
int declare_log_constants(PyObject *aerospike)
{

// Status to be returned.
as_status status = AEROSPIKE_OK;

// Check if aerospike object is present or no.
if (!aerospike) {
status = AEROSPIKE_ERR;
goto exit;
}

// Add incidividual constants to aerospike module.

PyModule_AddIntConstant(aerospike, "LOG_LEVEL_OFF", LOG_LEVEL_OFF);
PyModule_AddIntConstant(aerospike, "LOG_LEVEL_ERROR", LOG_LEVEL_ERROR);
PyModule_AddIntConstant(aerospike, "LOG_LEVEL_WARN", LOG_LEVEL_WARN);
PyModule_AddIntConstant(aerospike, "LOG_LEVEL_INFO", LOG_LEVEL_INFO);
PyModule_AddIntConstant(aerospike, "LOG_LEVEL_DEBUG", LOG_LEVEL_DEBUG);
PyModule_AddIntConstant(aerospike, "LOG_LEVEL_TRACE", LOG_LEVEL_TRACE);
exit:
return status;
return 0;
}

PyObject *Aerospike_Set_Log_Level(PyObject *parent, PyObject *args,
Expand Down
30 changes: 16 additions & 14 deletions src/main/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,27 +552,29 @@ as_status set_query_options(as_error *err, PyObject *query_options,
/**
* Declares policy constants.
*/
as_status declare_policy_constants(PyObject *aerospike)
int declare_policy_constants(PyObject *aerospike)
{
as_status status = AEROSPIKE_OK;
// TODO: Clean up enums / structs used to define these constants
int i;

if (!aerospike) {
status = AEROSPIKE_ERR;
goto exit;
}
int retval = 0;
for (i = 0; i < (int)AEROSPIKE_CONSTANTS_ARR_SIZE; i++) {
PyModule_AddIntConstant(aerospike, aerospike_constants[i].constant_str,
aerospike_constants[i].constantno);
retval = PyModule_AddIntConstant(aerospike,
aerospike_constants[i].constant_str,
aerospike_constants[i].constantno);
if (retval == -1) {
return -1;
}
}

for (i = 0; i < (int)AEROSPIKE_JOB_CONSTANTS_ARR_SIZE; i++) {
PyModule_AddStringConstant(aerospike,
aerospike_job_constants[i].exposed_job_str,
aerospike_job_constants[i].job_str);
retval = PyModule_AddStringConstant(
aerospike, aerospike_job_constants[i].exposed_job_str,
aerospike_job_constants[i].job_str);
if (retval == -1) {
return -1;
}
}
exit:
return status;
return 0;
}

/**
Expand Down

0 comments on commit 9ce9f15

Please sign in to comment.