【发布时间】:2020-02-23 13:38:05
【问题描述】:
我有一个由云 Pub/Sub 触发的云功能。我想要使用 Python SDK 的相同函数触发数据流。这是我的代码:
import base64
def hello_pubsub(event, context):
if 'data' in event:
message = base64.b64decode(event['data']).decode('utf-8')
else:
message = 'hello world!'
print('Message of pubsub : {}'.format(message))
我是这样部署函数的:
gcloud beta functions deploy hello_pubsub --runtime python37 --trigger-topic topic1
【问题讨论】:
-
数据流管道的代码在哪里?在模板中?在外部文件中?
-
在 python 文件中。我在谷歌外壳上工作
标签: python-3.x google-cloud-platform google-cloud-functions google-cloud-dataflow google-cloud-pubsub