Skip to content

Commit d2dfe3c

Browse files
weltekialexellis
authored andcommitted
Add documentation for Google Cloud Pub/Sub connector
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <[email protected]>
1 parent 2222aaa commit d2dfe3c

File tree

5 files changed

+89
-1
lines changed

5 files changed

+89
-1
lines changed

docs/openfaas-pro/introduction.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ Identity Access Management (IAM) and Policy-based authorization is available for
248248
| [Kafka event trigger](/openfaas-pro/kafka-events) | Not supported | Supports SASL or TLS auth, Aiven, Confluent and self-hosted | Support with SLA |
249249
| [Postgres trigger](/openfaas-pro/postgres-events) | Not supported | Supports insert, update and delete, with table-level filters using WAL or LISTEN/NOTIFY. | Support with SLA |
250250
| [AWS SQS trigger](/openfaas-pro/sqs-events) | Not supported | Standard support | Support with SLA |
251+
| [AWS SNS trigger](/openfaas-pro/sns-events) | Not supported | Standard support | Support with SLA |
252+
| [RabbitMQ trigger](/openfaas-pro/rabbitmq-events) | Not supported | Standard support | Support with SLA |
253+
| [Google Cloud Pub/Sub trigger](/openfaas-pro/pubsub-events) | Not supported | Standard support | Support with SLA |
251254
| [Cron and scheduled invocations](/reference/cron) | Community support | Standard support | Support with SLA |
252255

253256
**Durability and reliability**

docs/openfaas-pro/pubsub-events.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Trigger function from Google Cloud Pub/Sub events
2+
3+
Trigger OpenFaaS functions from Google Cloud Pub/Sub messages.
4+
5+
> Note: This feature is included for [OpenFaaS Standard & For Enterprises](https://openfaas.com/pricing/)
6+
7+
## Installation
8+
9+
* Setup the connector
10+
11+
You can install the Google Cloud Pub/Sub connector using its [helm chart](https://github.com/openfaas/faas-netes/tree/master/chart/gcp-pubsub-connector).
12+
13+
The `values.yaml` file can be customised to suit your needs.
14+
15+
* Configure the connector for your needs by defining a values.yaml file
16+
17+
```yaml
18+
# Google cloud project ID
19+
projectID: "openfaas-381517"
20+
21+
# List if Pub/Sub subscriptions the connector should subscribe to.
22+
subscriptions:
23+
- my-sub
24+
```
25+
26+
Use the `subscriptions` parameter to configure a list of Pub/Sub subscriptions to which the connector should subscribe. When the subscriber receives a message, the connector will attempt to invoke any function that has the subscription name listed in its `topic` annotation.
27+
28+
## Usage
29+
30+
To test the connector, you can deploy the [printer function](https://github.com/openfaas/store-functions/blob/master/printer/handler.go). It prints out the HTTP headers and body of any invocation.
31+
32+
Add an annotation `topic=sub1` so that the function is invoked for any message delivered to the `sub1` Pub/Sub subscription.
33+
34+
Each time a function is invoked by the connector it will receive the message body as the HTTP body. Message attributes are mapped to HTTP Headers.
35+
36+
```bash
37+
faas-cli store deploy printer \
38+
--annotation topic=sub1
39+
```
40+
41+
Use the [Google Cloud Console](https://console.cloud.google.com) or [gcloud CLI](https://cloud.google.com/pubsub/docs/publish-receive-messages-gcloud) to publish a message for testing.
42+
43+
```bash
44+
faas-cli logs printer
45+
46+
2025-04-02T11:40:50Z X-Pubsub-Attr-Foo=[Y]
47+
2025-04-02T11:40:50Z X-Pubsub-Msg-Id=[14373415254515458]
48+
2025-04-02T11:40:50Z User-Agent=[openfaas-gateway/0.4.39]
49+
2025-04-02T11:40:50Z Accept-Encoding=[gzip]
50+
2025-04-02T11:40:50Z X-Forwarded-For=[127.0.0.1:49964]
51+
2025-04-02T11:40:50Z X-Topic=[my-sub]
52+
2025-04-02T11:40:50Z X-Forwarded-Host=[127.0.0.1:8080]
53+
2025-04-02T11:40:50Z X-Pubsub-Publish-Time=[2025-04-02T11:40:49Z]
54+
2025-04-02T11:40:50Z X-Start-Time=[1743594050512199246]
55+
2025-04-02T11:40:50Z Content-Type=[text/plain]
56+
2025-04-02T11:40:50Z X-Call-Id=[f7fccd26-d8ee-4874-90e3-eefc94e2b74c]
57+
2025-04-02T11:40:50Z X-Connector=[connector-sdk openfaasltd/gcp-pubsub-connector]
58+
2025-04-02T11:40:50Z
59+
2025-04-02T11:40:50Z Hello OpenFaaS
60+
```
61+
62+
Additional headers are made available to the request. These headers contain any message attributes along with some metadata about the Pub/Sub message.
63+
64+
* `X-PubSub-Msg-ID` - the Pub/Sub message identifier.
65+
* `X-PubSub-Publish-Time` - the time at which the message was published.
66+
* `X-PubSub-Delivery-Attempt` - the number of times a message has been delivered.
67+
* `X-PubSub-Ordering-Key` - identifies related messages for which publish order should be respected.
68+
* `X-PubSub-Attr-<key>` - value of Pub/Sub message attribute.
69+
70+
So for example, if you added an attributed called `Foo` with a value of `Y`, you'd get the following extra header: `X-PubSub-Attr-Foo: Y`
71+
72+
The default content-type is configured as `text/plain`, but can be changed to another content-type such as `application/json` or `application/octet-stream` by the [values.yaml file](https://github.com/openfaas/faas-netes/blob/master/chart/gcp-pubsub-connector/values.yaml) for the connector.
73+
74+
## Would you like a demo?
75+
76+
Feel free to reach out to us for a demo or to ask any questions you may have.
77+
78+
* [Talk to us](https://openfaas.com/pricing/)

docs/openfaas-pro/rabbitmq-events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Additional headers are made available to the request. These headers contain Rabb
8181
* `X-Rabbitmq-Msg-Id` - the message identifier.
8282
* `X-Rabbitmq-Routing-Key` - the routing key of the message.
8383

84-
The default content-type is configured as `text/plain`, but can be changed to another content-type such as `application/json` or `application/octet-stream` by the [values.yaml file](https://github.com/openfaas/faas-netes/blob/master/chart/kafka-connector/values.yaml) for the connector.
84+
The default content-type is configured as `text/plain`, but can be changed to another content-type such as `application/json` or `application/octet-stream` by the [values.yaml file](https://github.com/openfaas/faas-netes/blob/master/chart/rabbitmq-connector/values.yaml) for the connector.
8585

8686
## Would you like a demo?
8787

docs/reference/triggers.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ If you are unable to expose a public endpoint for any reason, and still need eve
8585

8686
[Read the documentation](/openfaas-pro/sns-events)
8787

88+
### Google Cloud Pub/Sub
89+
90+
Trigger OpenFaaS functions from Google Cloud Pub/Sub messages.
91+
92+
[Read the documentation](/openfaas-pro/pubsub-events)
93+
8894
### RabbitMQ
8995

9096
Trigger your functions from messages published to RabbitMQ queues.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ nav:
166166
- AWS SQS events: ./openfaas-pro/sqs-events.md
167167
- AWS SNS events: ./openfaas-pro/sns-events.md
168168
- RabbitMQ events: ./openfaas-pro/rabbitmq-events.md
169+
- Google Cloud PubSub events: ./openfaas-pro/pubsub-events.md
169170
# - Federated Gateway: ./openfaas-pro/federated-gateway.md
170171
- Airgapped installation: ./openfaas-pro/airgap.md
171172
- Function Builder API: ./openfaas-pro/builder.md

0 commit comments

Comments
 (0)