Documentation for the datavillage python SDK (package dv_utils
)
dv_utils.settings
This module define the settings for the DV-utils package.
Settings
Settings for the application
Source code in dv_utils/settings.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
load_settings(dotenv_file=None)
load the settings from a file in argument, or in environment variable or default
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dotenv_file
|
str
|
path to a dotenv file. Defaults to None. |
None
|
Source code in dv_utils/settings.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
dv_utils.process
This module define a dummy event processor as an example.
process_event_dummy(evt)
Process an incoming event
Source code in dv_utils/process.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
dv_utils.listener
This module define a default redis event listener processor as an example.
DefaultListener
default listener for message on the the redis queue
Source code in dv_utils/listener.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
dv_utils.redis
This module define the RedisQueue handling class
RedisQueue
Client to the local redis queue exposed in the cage.
Source code in dv_utils/redis.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
create_consummer_group(stream_names=['events'])
Create the consummer group if it does not exist
Source code in dv_utils/redis.py
30 31 32 33 34 35 36 37 38 39 40 41 |
|
destroy_consummer_group()
Remove the consummer group if it exists
Source code in dv_utils/redis.py
43 44 45 46 47 |
|
listen_once(timeout=120, stream_name='events')
Listen to the redis queue until one message is obtained, or timeout is reached :param timeout: timeout delay in seconds :param stream_name: name of the stream to listen to :return: the received message, or None
Source code in dv_utils/redis.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
publish(data, create_consumer_group=False, stream_name='events')
publish an event to the redis queue
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
dict
|
event data to publish |
required |
create_consumer_group
|
bool
|
create the consummer group if it does not exist. Defaults to True. |
False
|
stream_name
|
str, default=events
|
the stream_name to publish the events to |
'events'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
message id |
Source code in dv_utils/redis.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|