diff --git a/README.md b/README.md index 4c139eae..109a211f 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,31 @@ def function(request): This function will catch the `ZeroDivisionError` and return a different response instead. +### Quickstart: With Pub/Sub Emulator + +1. Start Functions Frameworks in local development server listening on port 8082: + ```sh + functions-framework --target=hello --debug --port=8082 + ``` +1. Start Pub/Sub Emulator. + ```sh + export PUBSUB_PROJECT_ID=abc + gcloud beta emulators pubsub start \ + --project=$PUBSUB_PROJECT_ID \ + --host-port=localhost:8080 + ``` +1. Create a Pub/Sub topic and attach a push subscription to the topic, using `http://localhost:8082` as its push endpoint. Publish some messages to the topic. Observe your function getting triggered by Pub/Sub messages. + ```sh + export TOPIC_ID_=may + export PUSH_SUBSCRIPTION_ID=five + $(gcloud beta emulators pubsub env-init) + git clone https://github.com/googleapis/python-pubsub.git + cd python-pubsub/samples/snippets/ + python publisher.py $PUBSUB_PROJECT_ID create $TOPIC_ID + python subscriber.py $PUBSUB_PROJECT_ID create $TOPIC_ID $PUSH_SUBSCRIPTION_ID http://localhost:8082 + python publisher.py $PUBSUB_PROJECT_ID publish $TOPIC_ID + ``` + ### Quickstart: Build a Deployable Container 1. Install [Docker](https://store.docker.com/search?type=edition&offering=community) and the [`pack` tool](https://buildpacks.io/docs/install-pack/).