go-functions-sdk

module
v0.0.0-...-bdfd36d Latest Latest
Warning

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

Go to latest
Published: May 1, 2019 License: Apache-2.0

README

Importer beware this is a WORK IN PROGRESS

Unofficial golang cloud functions sdk

This projects aims to simplify the deployment process of golang cloud functions.

Code the functions and deploy with gocf deploy.

Install the functions package

go get github.com/dergoegge/go-functions-sdk

Function examples

package funcpackage

import (
	"context"
	"fmt"
	"net/http"

	"github.com/dergoegge/go-functions-sdk/pkg/functions"
)

var HTTPFuncName = functions.New().
	RunWith(functions.RuntimeOptions{
		Timeout: 70, // Timeout in seconds
		Memory:  "128MB",
	}).
	Region("us-central1").
	RetryOnFailure(true).
	OnRequest(func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "Yeet")
	})

var FirestoreFuncName = functions.New().
	RunWith(functions.RuntimeOptions{
		Timeout: 70,
		Memory:  "1GB",
	}).
	Region("europe-west2").
	Firestore().
	Document("some-collection/{docID}").
	OnWrite(func(ctx context.Context, event functions.FirestoreEvent) error {
		fmt.Println(event.Value.Fields)
		return nil
	})

More examples for different trigger types are located in the examples directory.

Supported trigger types

  • Http
  • Firestore
  • Storage
  • PubSub
  • Firebase authentication

More coming soon.

Install the deployment tool

gcloud auth login
gcloud config set project <project-id>

go install github.com/dergoegge/go-functions-sdk/cmd/gocf

Comands

Deploy cloud functions:
gocf deploy [--only "comma seperated list of functions to deploy"]

List deployed cloud functions:
gocf list

Directories

Path Synopsis
cmd
internal
pkg

Jump to

Keyboard shortcuts

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