dnaStreaming 2.2.0__tar.gz → 2.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dnastreaming-2.2.0/dnaStreaming.egg-info → dnastreaming-2.2.1}/PKG-INFO +2 -2
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/demo/show_ha_stream_async.py +3 -3
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/listener.py +5 -4
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/services/availability_service.py +9 -3
- {dnastreaming-2.2.0 → dnastreaming-2.2.1/dnaStreaming.egg-info}/PKG-INFO +2 -2
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/setup.py +1 -1
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/LICENSE +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/MANIFEST.in +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/README.rst +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/__init__.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/config.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/customer_config.json +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/demo/__init__.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/demo/pubsub_stream.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/demo/show_stream.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/demo/show_stream_async.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/services/__init__.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/services/authentication_service.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/services/credentials_service.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/services/pubsub_service.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/test/__init__.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming/test/test_config.py +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming.egg-info/SOURCES.txt +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming.egg-info/dependency_links.txt +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming.egg-info/requires.txt +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/dnaStreaming.egg-info/top_level.txt +0 -0
- {dnastreaming-2.2.0 → dnastreaming-2.2.1}/setup.cfg +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dnaStreaming
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Dow Jones DNA Streaming Project
|
|
5
5
|
Home-page: https://github.com/dowjones/dj-dna-streams-python
|
|
6
|
-
Download-URL: https://github.com/dowjones/dj-dna-streams-python/archive/release-2.2.
|
|
6
|
+
Download-URL: https://github.com/dowjones/dj-dna-streams-python/archive/release-2.2.1.tar.gz
|
|
7
7
|
Author: Zachary Kagan
|
|
8
8
|
Author-email: zachary.kagan@dowjones.com
|
|
9
9
|
License: MIT
|
|
@@ -4,7 +4,7 @@ from dnaStreaming.listener import Listener
|
|
|
4
4
|
|
|
5
5
|
listener = Listener()
|
|
6
6
|
quiet_demo = os.getenv('QUIET_DEMO', "false") == "true"
|
|
7
|
-
max_secs =
|
|
7
|
+
max_secs = 1000
|
|
8
8
|
print("\n[ACTIVITY] Receiving messages (ASYNC) for {} seconds...\n[0]".format(max_secs), end='')
|
|
9
9
|
|
|
10
10
|
|
|
@@ -12,9 +12,9 @@ def callback(message, subscription_id):
|
|
|
12
12
|
callback.counter += 1
|
|
13
13
|
if not quiet_demo:
|
|
14
14
|
if message['action'] != 'del':
|
|
15
|
-
print('[INFO] [MSG] [{}]: AN: {}, TITLE: {}'.format(callback.counter, message['an'], message['title']))
|
|
15
|
+
print('[INFO] [SUBSCRIPTION]: {} [MSG] [{}]: AN: {}, TITLE: {}'.format(subscription_id, callback.counter, message['an'], message['title']))
|
|
16
16
|
else:
|
|
17
|
-
print('[INFO] [MSG] [{}]: AN: {}, *** DELETE ***'.format(callback.counter, message['an']))
|
|
17
|
+
print('[INFO] [SUBSCRIPTION]: {} [MSG] [{}]: AN: {}, *** DELETE ***'.format(subscription_id, callback.counter, message['an']))
|
|
18
18
|
else:
|
|
19
19
|
if callback.counter % 10 == 0:
|
|
20
20
|
print('[{}]'.format(callback.counter), end='')
|
|
@@ -125,19 +125,20 @@ class Listener(object):
|
|
|
125
125
|
'Listeners for subscriptions have been configured, set and await message arrival.')
|
|
126
126
|
return subscription
|
|
127
127
|
|
|
128
|
-
def listen_async_ha(self, on_message_callback
|
|
129
|
-
def ack_message_and_callback(message):
|
|
128
|
+
def listen_async_ha(self, on_message_callback):
|
|
129
|
+
def ack_message_and_callback(message, subscription_path):
|
|
130
130
|
pubsub_msg = json.loads(message.data)
|
|
131
131
|
logger.info("Received news message with ID: {}".format(
|
|
132
132
|
pubsub_msg['data'][0]['id']))
|
|
133
133
|
news_msg = pubsub_msg['data'][0]['attributes']
|
|
134
|
-
|
|
134
|
+
short_subscription_id = subscription_path.split("/")[-1]
|
|
135
|
+
on_message_callback(news_msg, short_subscription_id)
|
|
135
136
|
message.ack()
|
|
136
137
|
|
|
137
138
|
main_pubsub_client = pubsub_service.get_client(self.config, MAIN_REGION)
|
|
138
139
|
backup_pubsub_client = pubsub_service.get_client(self.config, BACKUP_REGION)
|
|
139
140
|
|
|
140
|
-
subscription_id =
|
|
141
|
+
subscription_id = self.config.subscription()
|
|
141
142
|
|
|
142
143
|
if not subscription_id:
|
|
143
144
|
raise Exception(
|
|
@@ -38,8 +38,14 @@ def ha_listen(api_host, user_key, subscription_id, stop_event, main_subscription
|
|
|
38
38
|
|
|
39
39
|
current_region = MAIN_REGION
|
|
40
40
|
|
|
41
|
+
def wrapped_callback(subscription_path):
|
|
42
|
+
def inner_callback(message):
|
|
43
|
+
callback(message, subscription_path)
|
|
44
|
+
|
|
45
|
+
return inner_callback
|
|
46
|
+
|
|
41
47
|
streaming_pull_future = main_pubsub_client.subscribe(
|
|
42
|
-
|
|
48
|
+
main_subscription_path, callback=wrapped_callback(main_subscription_path))
|
|
43
49
|
|
|
44
50
|
while not stop_event.is_set():
|
|
45
51
|
|
|
@@ -65,10 +71,10 @@ def ha_listen(api_host, user_key, subscription_id, stop_event, main_subscription
|
|
|
65
71
|
|
|
66
72
|
if active_region == MAIN_REGION:
|
|
67
73
|
streaming_pull_future = main_pubsub_client.subscribe(
|
|
68
|
-
main_subscription_path, callback=
|
|
74
|
+
main_subscription_path, callback=wrapped_callback(main_subscription_path))
|
|
69
75
|
else: # active_region == BACKUP_REGION
|
|
70
76
|
streaming_pull_future = backup_pubsub_client.subscribe(
|
|
71
|
-
backup_subscription_path, callback=
|
|
77
|
+
backup_subscription_path, callback=wrapped_callback(backup_subscription_path))
|
|
72
78
|
|
|
73
79
|
logger.warning(f"Started listener in region {active_region}")
|
|
74
80
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dnaStreaming
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Dow Jones DNA Streaming Project
|
|
5
5
|
Home-page: https://github.com/dowjones/dj-dna-streams-python
|
|
6
|
-
Download-URL: https://github.com/dowjones/dj-dna-streams-python/archive/release-2.2.
|
|
6
|
+
Download-URL: https://github.com/dowjones/dj-dna-streams-python/archive/release-2.2.1.tar.gz
|
|
7
7
|
Author: Zachary Kagan
|
|
8
8
|
Author-email: zachary.kagan@dowjones.com
|
|
9
9
|
License: MIT
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|