main.py
Go to the documentation of this file.
1 # Copyright 2022 gRPC authors.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import functions_framework
16 from google.cloud import pubsub_v1
17 
18 ps_client = pubsub_v1.PublisherClient()
19 _PROJECT_ID = "grpc-testing"
20 _PUBSUB_TOPIC = 'gcf-distribtest-topic'
21 
22 
23 @functions_framework.http
24 def test_publish(request):
25  topic_path = ps_client.topic_path(_PROJECT_ID, _PUBSUB_TOPIC)
26  message = '{"function": "TEST"}'
27  message_bytes = message.encode('utf-8')
28 
29  for _ in range(100):
30  future = ps_client.publish(topic_path, data=message_bytes)
31 
32  return "ok", 200
capstone.range
range
Definition: third_party/bloaty/third_party/capstone/bindings/python/capstone/__init__.py:6
main.test_publish
def test_publish(request)
Definition: main.py:24


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:30