项目作者: dergoegge

项目描述 :
Golang cloud functions sdk
高级语言: Go
项目地址: git://github.com/dergoegge/go-functions-sdk.git
创建时间: 2019-04-10T15:40:28Z
项目社区:https://github.com/dergoegge/go-functions-sdk

开源协议:Apache License 2.0

下载


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

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

Function examples

  1. package funcpackage
  2. import (
  3. "context"
  4. "fmt"
  5. "net/http"
  6. "github.com/dergoegge/go-functions-sdk/pkg/functions"
  7. )
  8. var HTTPFuncName = functions.New().
  9. RunWith(functions.RuntimeOptions{
  10. Timeout: 70, // Timeout in seconds
  11. Memory: "128MB",
  12. }).
  13. Region("us-central1").
  14. RetryOnFailure(true).
  15. OnRequest(func(w http.ResponseWriter, r *http.Request) {
  16. fmt.Fprintf(w, "Yeet")
  17. })
  18. var FirestoreFuncName = functions.New().
  19. RunWith(functions.RuntimeOptions{
  20. Timeout: 70,
  21. Memory: "1GB",
  22. }).
  23. Region("europe-west2").
  24. Firestore().
  25. Document("some-collection/{docID}").
  26. OnWrite(func(ctx context.Context, event functions.FirestoreEvent) error {
  27. fmt.Println(event.Value.Fields)
  28. return nil
  29. })

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

  1. gcloud auth login
  2. gcloud config set project <project-id>
  3. 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