helloworld

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

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

Hello World Samples

System Tests

Storage
  1. export BUCKET_NAME=...

  2. gsutil mb gs://$BUCKET_NAME

  3. gcloud functions deploy HelloGCS --runtime=go113 --entry-point=HelloGCS --trigger-resource=$BUCKET_NAME --trigger-event=providers/cloud.storage/eventTypes/object.change

  4. go test -v ./hello_cloud_storage_system_test.go

HTTP
  1. gcloud functions deploy HelloHTTP --region=us-central1 --runtime=go113 --trigger-http

  2. export BASE_URL=https://REGION-PROJECT.cloudfunctions.net/

  3. go test -v ./hello_http_system_test.go

Pub/Sub
  1. export FUNCTIONS_TOPIC=example-topic

  2. gcloud functions deploy HelloPubSub --runtime=go113 --trigger-topic=$FUNCTIONS_TOPIC

  3. go test -v ./hello_pubsub_system_test.go

Documentation

Overview

Package helloworld provides a set of Cloud Functions samples.

Package helloworld provides a set of Cloud Functions samples.

Package helloworld provides a set of Cloud Functions samples.

Package helloworld provides a set of Cloud Functions samples.

Package helloworld provides a set of Cloud Functions samples.

Package helloworld provides a set of Cloud Functions samples.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HelloGCS

func HelloGCS(ctx context.Context, e GCSEvent) error

HelloGCS consumes a(ny) GCS event.

func HelloGet

func HelloGet(w http.ResponseWriter, r *http.Request)

HelloGet is an HTTP Cloud Function.

func HelloHTTP

func HelloHTTP(w http.ResponseWriter, r *http.Request)

HelloHTTP is an HTTP Cloud Function with a request parameter.

func HelloLogging

func HelloLogging(w http.ResponseWriter, r *http.Request)

HelloLogging logs messages.

func HelloPubSub

func HelloPubSub(ctx context.Context, m PubSubMessage) error

HelloPubSub consumes a Pub/Sub message.

func HelloRemoteConfig

func HelloRemoteConfig(ctx context.Context, e RemoteConfigEvent) error

HelloRemoteConfig handles Firebase Remote Config events.

Types

type GCSEvent

type GCSEvent struct {
	Kind                    string                 `json:"kind"`
	ID                      string                 `json:"id"`
	SelfLink                string                 `json:"selfLink"`
	Name                    string                 `json:"name"`
	Bucket                  string                 `json:"bucket"`
	Generation              string                 `json:"generation"`
	Metageneration          string                 `json:"metageneration"`
	ContentType             string                 `json:"contentType"`
	TimeCreated             time.Time              `json:"timeCreated"`
	Updated                 time.Time              `json:"updated"`
	TemporaryHold           bool                   `json:"temporaryHold"`
	EventBasedHold          bool                   `json:"eventBasedHold"`
	RetentionExpirationTime time.Time              `json:"retentionExpirationTime"`
	StorageClass            string                 `json:"storageClass"`
	TimeStorageClassUpdated time.Time              `json:"timeStorageClassUpdated"`
	Size                    string                 `json:"size"`
	MD5Hash                 string                 `json:"md5Hash"`
	MediaLink               string                 `json:"mediaLink"`
	ContentEncoding         string                 `json:"contentEncoding"`
	ContentDisposition      string                 `json:"contentDisposition"`
	CacheControl            string                 `json:"cacheControl"`
	Metadata                map[string]interface{} `json:"metadata"`
	CRC32C                  string                 `json:"crc32c"`
	ComponentCount          int                    `json:"componentCount"`
	Etag                    string                 `json:"etag"`
	CustomerEncryption      struct {
		EncryptionAlgorithm string `json:"encryptionAlgorithm"`
		KeySha256           string `json:"keySha256"`
	}
	KMSKeyName    string `json:"kmsKeyName"`
	ResourceState string `json:"resourceState"`
}

GCSEvent is the payload of a GCS event.

type PubSubMessage

type PubSubMessage struct {
	Data []byte `json:"data"`
}

PubSubMessage is the payload of a Pub/Sub event. See the documentation for more details: https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage

type RemoteConfigEvent

type RemoteConfigEvent struct {
	UpdateOrigin string `json:"updateOrigin"`
	UpdateType   string `json:"updateType"`
	UpdateUser   struct {
		Email    string `json:"email"`
		ImageURL string `json:"imageUrl"`
		Name     string `json:"name"`
	} `json:"updateUser"`
	VersionNumber string `json:"versionNumber"`
}

A RemoteConfigEvent is an event triggered by Firebase Remote Config.

Jump to

Keyboard shortcuts

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