Skip to content

Commit 3b3b98a

Browse files
authored
Merge pull request #96 from splitio/feature/DocumentationRedisSentinel
[SDKS-136]: [Python] Documentation for Redis Sentinel
2 parents f5941c6 + 86ad3b4 commit 3b3b98a

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

Detailed-README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,84 @@ The following snippet shows you how to create a basic client using the default c
3232
'SOME_TREATMENT'
3333
```
3434

35+
## Logging
36+
Split SDK uses logging module from Python.
37+
38+
### Logging sample
39+
```python
40+
import logging
41+
logging.basicConfig(level=logging.DEBUG)
42+
```
43+
44+
## Cache
45+
Split SDK depends on the popular [redis-py](https://github.com/andymccurdy/redis-py) library.
46+
47+
### Cache Adapter
48+
The redis-py library is supported as the python interface to the Redis key-value store. This library uses a connection pool to manage connections to a Redis server. For further information about how to configure the ```redis-py``` client, please take a look on [redis-py official docs](https://github.com/andymccurdy/redis-py)
49+
50+
For ```redis``` and their dependencies such as ```jsonpickle``` you can use ```pip``` running the command ```pip install splitio_client[redis,cpphash]==5.5.0```
51+
52+
#### Provided redis-py connection - sample code
53+
```python
54+
#Default imports
55+
from __future__ import print_function
56+
57+
import sys
58+
59+
from splitio import get_factory
60+
from splitio.exceptions import TimeoutException
61+
62+
# redis-py options
63+
'''The options below, will be loaded as:
64+
r = redis.StrictRedis(host='localhost', port=6379, db=0, prefix='')
65+
'''
66+
config = {
67+
'redisDb' : 0,
68+
'redisHost' : 'localhost',
69+
'redisPosrt': 6379,
70+
'redisPrefix': ''
71+
}
72+
73+
# Create the Split Client instance.
74+
try:
75+
factory = get_factory('API_KEY', config=config)
76+
split = factory.client()
77+
except TimeoutException:
78+
sys.exit()
79+
```
80+
81+
#### Provided redis-py connection - sample code for Sentinel Support
82+
```python
83+
#Default imports
84+
from __future__ import print_function
85+
86+
import sys
87+
88+
from splitio import get_factory
89+
from splitio.exceptions import TimeoutException
90+
91+
# redis-py options
92+
'''
93+
The options below, will be loaded as:
94+
sentinel = Sentinel(redisSentinels, { db: redisDb, socket_timeout: redisSocketTimeout })
95+
master = sentinel.master_for(redisMasterService)
96+
'''
97+
config = {
98+
'redisDb': 0,
99+
'redisPrefix': '',
100+
'redisSentinels': [('IP', PORT), ('IP', PORT), ('IP', PORT)],
101+
'redisMasterService': 'SERVICE_MASTER_NAME',
102+
'redisSocketTimeout': 3
103+
}
104+
105+
# Create the Split Client instance.
106+
try:
107+
factory = get_factory('API_KEY', config=config)
108+
split = factory.client()
109+
except TimeoutException:
110+
sys.exit()
111+
```
112+
35113
## Additional information
36114

37115
You can get more information on how to use this package in the included documentation.

0 commit comments

Comments
 (0)