-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(example): add a simple example to test google-pubsub
- Loading branch information
1 parent
30f3947
commit f58b49e
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# PubSub Example: Google Cloud Pub/Sub | ||
|
||
Sample Express application in order to test the @algoan/pubsub library with Google Pub/Sub. | ||
|
||
## Getting Started | ||
|
||
Install dependencies: | ||
|
||
```shell | ||
npm i | ||
``` | ||
|
||
Run a google Pub/Sub emulator using gcloud CLI. You must ensure that `beta` and `pubsub-emulator` are installed: | ||
|
||
```shell | ||
gcloud components install pubsub-emulator | ||
gcloud components install beta | ||
gcloud components update | ||
```` | ||
|
||
You can also run the emulator using Docker: | ||
|
||
```shell | ||
docker pull google/cloud-sdk:emulators | ||
docker run --rm -p 8085:8085 google/cloud-sdk:emulators /bin/bash -c "gcloud beta emulators pubsub start --project=test --host-port='0.0.0.0:8085'" | ||
``` | ||
|
||
Then, run: | ||
|
||
```shell | ||
npm start | ||
``` | ||
|
||
Navigate on http://localhost:3000! To emit an event, simply call GET http://localhost:3000/emit. To close the subscription server collection, call the GET http://localhost:3000/close API. |