Skip to content

Commit

Permalink
Merge pull request #239 from aerospike/3.7.2-candidate
Browse files Browse the repository at this point in the history
3.7.2 candidate
  • Loading branch information
marknaero authored Jul 3, 2019
2 parents 2c5abbe + e29f7e6 commit e76e567
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ python:
sudo: false
os:
- linux
dist: trusty
dist: xenial
addons:
apt:
packages:
- libssl-dev
- python-dev
install:
- wget -O aerospike-server.tgz http://aerospike.com/download/server/latest/artifact/tgz
- wget -O aerospike-server.tgz https://aerospike.com/download/server/latest/artifact/tgz
- tar xvzf aerospike-server.tgz
- cp -f .travis/aerospike.conf ./aerospike-server/share/etc
- cd aerospike-server
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.1
3.7.2
7 changes: 7 additions & 0 deletions doc/aerospike.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ in an in-memory primary index.
against it, such as :meth:`~aerospike.Client.put` and
:meth:`~aerospike.Client.get` records.

This is a wrapper function which calls the constructor for the :class:`~aerospike.Client` class.
The client may also be constructed by calling the constructor directly.

:param dict config: the client's configuration.

.. hlist::
Expand Down Expand Up @@ -116,6 +119,10 @@ in an in-memory primary index.
| This serves to lower cloud provider costs when nodes are distributed across different racks/data centers.
| **rack_id** and **POLICY_REPLICA_PREFER_RACK** and server rack configuration must also be set to enable this functionality.
| Default False
* **use_services_alternate**
| Boolean. Flag to signify if "services-alternate" should be used instead of "services"
| Default False

:return: an instance of the :py:class:`aerospike.Client` class.

Expand Down
2 changes: 1 addition & 1 deletion src/main/aerospike.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ AerospikeConstants operator_constants[] = {
MOD_INIT(aerospike)
{

const char version[8] = "3.7.1";
const char version[8] = "3.7.2";
// Makes things "thread-safe"
PyEval_InitThreads();
int i = 0;
Expand Down
23 changes: 20 additions & 3 deletions src/main/client/type.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@


static int set_rack_aware_config(as_config* conf, PyObject* config_dict);
static int set_use_services_alternate(as_config* conf, PyObject* config_dict);

enum {INIT_SUCCESS, INIT_NO_CONFIG_ERR, INIT_CONFIG_TYPE_ERR, INIT_LUA_USER_ERR,
INIT_LUA_SYS_ERR, INIT_HOST_TYPE_ERR, INIT_EMPTY_HOSTS_ERR,
Expand Down Expand Up @@ -1270,10 +1271,13 @@ static int AerospikeClient_Type_Init(AerospikeClient * self, PyObject * args, Py
}

if (set_rack_aware_config(&config, py_config) != INIT_SUCCESS) {

return INIT_POLICY_PARAM_ERR;
error_code = INIT_POLICY_PARAM_ERR;
goto CONSTRUCTOR_ERROR;
}
if (set_use_services_alternate(&config, py_config) != INIT_SUCCESS) {
error_code = INIT_POLICY_PARAM_ERR;
goto CONSTRUCTOR_ERROR;
}


PyObject* py_max_socket_idle = NULL;
py_max_socket_idle = PyDict_GetItemString(py_config, "max_socket_idle");
Expand Down Expand Up @@ -1387,6 +1391,19 @@ static int set_rack_aware_config(as_config*conf, PyObject* config_dict) {
return INIT_SUCCESS;
}

static int set_use_services_alternate(as_config* conf, PyObject* config_dict) {
PyObject* py_config_value;
py_config_value = PyDict_GetItemString(config_dict, "use_services_alternate");
if (py_config_value) {
if (PyBool_Check(py_config_value)) {
conf->use_services_alternate = PyObject_IsTrue(py_config_value);
} else {
return INIT_POLICY_PARAM_ERR; // A non boolean was passed in as the value of use_services_alternate
}
}
return INIT_SUCCESS;
}

static void AerospikeClient_Type_Dealloc(PyObject * self)
{

Expand Down
13 changes: 13 additions & 0 deletions test/new_tests/test_new_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def test_setting_rack_aware_and_rack_id():
client = aerospike.client(config)
assert client is not None

def test_setting_use_services_alternate():
config = {'hosts': host, 'use_services_alternate': True}
client = aerospike.client(config)
assert client is not None

def test_setting_rack_aware_non_bool():
config = {'hosts': host, 'rack_aware': "True"}
with pytest.raises(e.ParamError):
Expand All @@ -102,3 +107,11 @@ def test_setting_rack_id_wrong_type(rack_id):
config = {'hosts': host, 'rack_id': rack_id}
with pytest.raises(e.ParamError):
client = aerospike.client(config)

def test_setting_wrong_type_services_alternate():
'''
'use_services_alternate' should be a boolean
'''
config = {'hosts': host, 'use_services_alternate': "True"}
with pytest.raises(e.ParamError):
client = aerospike.client(config)

0 comments on commit e76e567

Please sign in to comment.