plexflow 0.0.91__py3-none-any.whl → 0.0.93__py3-none-any.whl
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.
- plexflow/utils/google/pubsub/consume.py +37 -0
- plexflow/utils/google/pubsub/produce.py +21 -0
- {plexflow-0.0.91.dist-info → plexflow-0.0.93.dist-info}/METADATA +1 -1
- {plexflow-0.0.91.dist-info → plexflow-0.0.93.dist-info}/RECORD +6 -4
- {plexflow-0.0.91.dist-info → plexflow-0.0.93.dist-info}/WHEEL +0 -0
- {plexflow-0.0.91.dist-info → plexflow-0.0.93.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
from google.cloud import pubsub_v1
|
2
|
+
import json
|
3
|
+
|
4
|
+
def consume_message(topic_id: str, project_id: str, as_json: bool = True, timeout: int = 5):
|
5
|
+
subscriber = pubsub_v1.SubscriberClient()
|
6
|
+
# The `subscription_path` method creates a fully qualified identifier
|
7
|
+
# in the form `projects/{project_id}/subscriptions/{subscription_id}`
|
8
|
+
subscription_path = subscriber.subscription_path(project_id, topic_id)
|
9
|
+
|
10
|
+
data = None
|
11
|
+
|
12
|
+
def callback(message: pubsub_v1.subscriber.message.Message) -> None:
|
13
|
+
nonlocal data
|
14
|
+
|
15
|
+
print(f"Received {message}.")
|
16
|
+
print(message.data.decode())
|
17
|
+
if as_json:
|
18
|
+
data = json.loads(message.data.decode())
|
19
|
+
else:
|
20
|
+
data = message.data.decode()
|
21
|
+
|
22
|
+
message.ack()
|
23
|
+
|
24
|
+
streaming_pull_future = subscriber.subscribe(subscription_path, callback=callback)
|
25
|
+
print(f"Listening for messages on {subscription_path}..\n")
|
26
|
+
|
27
|
+
# Wrap subscriber in a 'with' block to automatically call close() when done.
|
28
|
+
with subscriber:
|
29
|
+
try:
|
30
|
+
# When `timeout` is not set, result() will block indefinitely,
|
31
|
+
# unless an exception is encountered first.
|
32
|
+
streaming_pull_future.result(timeout=timeout)
|
33
|
+
except TimeoutError:
|
34
|
+
streaming_pull_future.cancel() # Trigger the shutdown.
|
35
|
+
streaming_pull_future.result() # Block until the shutdown is complete.
|
36
|
+
|
37
|
+
return data
|
@@ -0,0 +1,21 @@
|
|
1
|
+
from google.cloud import pubsub_v1
|
2
|
+
import json
|
3
|
+
|
4
|
+
def produce_message(value, topic_id: str, project_id: str, as_json: bool = True):
|
5
|
+
publisher = pubsub_v1.PublisherClient()
|
6
|
+
# The `topic_path` method creates a fully qualified identifier
|
7
|
+
# in the form `projects/{project_id}/topics/{topic_id}`
|
8
|
+
topic_path = publisher.topic_path(project_id, topic_id)
|
9
|
+
|
10
|
+
if as_json:
|
11
|
+
data_str = json.dumps(value)
|
12
|
+
else:
|
13
|
+
data_str = str(value)
|
14
|
+
|
15
|
+
# Data must be a bytestring
|
16
|
+
data = data_str.encode("utf-8")
|
17
|
+
# When you publish a message, the client returns a future.
|
18
|
+
future = publisher.publish(topic_path, data)
|
19
|
+
print(future.result())
|
20
|
+
|
21
|
+
print(f"Published messages to {topic_path}.")
|
@@ -588,6 +588,8 @@ plexflow/utils/filesystem/search.py,sha256=ed2ixbx5r2z_xtk19--Dfi5KK9g3HcsaAk0sq
|
|
588
588
|
plexflow/utils/gmail/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
589
589
|
plexflow/utils/gmail/__pycache__/mails.cpython-311.pyc,sha256=FAYfZzjLVqpPMjrEYcrOIsohtWrZYYXOZSUHod3r8Qg,7239
|
590
590
|
plexflow/utils/gmail/mails.py,sha256=hQIXiYR5LYeoiSH_lhbVM9criDBnTeCNmpZ5tvuUnsA,4562
|
591
|
+
plexflow/utils/google/pubsub/consume.py,sha256=MG4bW0D2s_38xO88b_3-K8PtknNCxPnCVtPtnQzoHgA,1408
|
592
|
+
plexflow/utils/google/pubsub/produce.py,sha256=AFlf6QZl6owA4QNzgrmed-d8lFbhsy-0bnMVVbAGNt4,713
|
591
593
|
plexflow/utils/hooks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
592
594
|
plexflow/utils/hooks/__pycache__/__init__.cpython-311.pyc,sha256=vlT8vFKsxMRss2XuHLM6ouyTl7Wk1To76MVYXowIABs,170
|
593
595
|
plexflow/utils/hooks/__pycache__/__init__.cpython-312.pyc,sha256=c2gIcwOonxPVWWXQE6C3BgiQ7CBIM4EOrvTxD0TIbyw,158
|
@@ -675,7 +677,7 @@ plexflow/utils/video/__pycache__/audio.cpython-312.pyc,sha256=vXBnJwWgTDFdixMBs-
|
|
675
677
|
plexflow/utils/video/__pycache__/subtitle.cpython-312.pyc,sha256=PCjpCLydGXaRsQy6cikhgsEs8WlComfOoYPiLFqfVMA,2515
|
676
678
|
plexflow/utils/video/audio.py,sha256=tJ_lNwcjVuBQYD5cYOlXpr__eh8-hnReIgNRgIYOpqo,3380
|
677
679
|
plexflow/utils/video/subtitle.py,sha256=LOGONGxs_RzmqtGP-DBKreOzS1eUFEKo75Q6AfnavW0,1290
|
678
|
-
plexflow-0.0.
|
679
|
-
plexflow-0.0.
|
680
|
-
plexflow-0.0.
|
681
|
-
plexflow-0.0.
|
680
|
+
plexflow-0.0.93.dist-info/METADATA,sha256=OQlrJ20U88D_hDuRNKi1m4aOWdaXce0IRjObp9M8qUM,2953
|
681
|
+
plexflow-0.0.93.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
|
682
|
+
plexflow-0.0.93.dist-info/entry_points.txt,sha256=aEqDHlozu_zjWrl2sibtrqtQHMgU8kSJZrE782CP47g,1362
|
683
|
+
plexflow-0.0.93.dist-info/RECORD,,
|
File without changes
|
File without changes
|