helloworld

package module
v0.0.0-...-4a2bb87 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

PubSub Event (Gen 2)

This project is a getting starter guide for working with a Pub/Sub event handling Cloud Functions.

Download template locally with gonew

  • Install gonew if you have not already.
go install golang.org/x/tools/cmd/gonew@latest
  • Download this template locally:
gonew github.com/GoogleCloudPlatform/go-templates/functions/pubsubfn your.domain/pubsubfn

Deploy

# The name of the Pub/Sub topic that the Cloud Function will listen on
EXPORT TOPIC_NAME=func-test

# Create the Pub/Sub Topic
gcloud pubsub topics create $TOPIC_NAME

# Deploy the Cloud Function
gcloud functions deploy hello-pubsub \
--gen2 \
--runtime=go122 \
--region=us-central1 \
--source=. \
--entry-point=HelloPubSub \
--trigger-topic=func-test

# Send a test message to your topic
gcloud pubsub topics publish $$TOPIC_NAME --message="Test message from gcloud"

Resources

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessagePublishedData

type MessagePublishedData struct {
	Message struct {
		Data []byte `json:"data"`
	} `json:"message"`
}

MessagePublishedData contains the full Pub/Sub message See the documentation for more details: https://cloud.google.com/eventarc/docs/cloudevents#pubsub

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL