functions

package
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 Imports: 5 Imported by: 5

Documentation

Index

Constants

View Source
const (
	AuthUserCreate string = "providers/firebase.auth/eventTypes/user.create"
	AuthUserDelete string = "providers/firebase.auth/eventTypes/user.delete"
)

Firebase authentication event names

View Source
const (
	FirestoreOnCreate string = "providers/cloud.firestore/eventTypes/document.create"
	FirestoreOnUpdate string = "providers/cloud.firestore/eventTypes/document.update"
	FirestoreOnDelete string = "providers/cloud.firestore/eventTypes/document.delete"
	FirestoreOnWrite  string = "providers/cloud.firestore/eventTypes/document.write"
)

Firestore event names

View Source
const (
	StorageOnArchive        string = "google.storage.object.archive"
	StorageOnDelete         string = "google.storage.object.delete"
	StorageOnFinalize       string = "google.storage.object.finalize"
	StorageOnMetadataUpdate string = "google.storage.object.metadataUpdate"
)

Storage event names

View Source
const (
	PubSubPublish = "google.pubsub.topic.publish"
)

PubSub event names

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthEvent

type AuthEvent struct {
	UID string `json:"uid"`

	Email         string `json:"email"`
	EmailVerified bool   `json:"emailVerified"`
	DisplayName   string `json:"displayName"`
	PhotoURL      string `json:"photoURL"`

	ProviderData []struct {
		UID         string `json:"uid"`
		Email       string `json:"email"`
		DisplayName string `json:"displayName"`
		PhotoURL    string `json:"photoURL"`
		ProviderID  string `json:"providerId"`
	} `json:"providerData"`

	CustomClaims *interface{} `json:"customClaims"`

	Disabled bool `json:"disabled"`
	Metadata struct {
		CreatedAt      time.Time `json:"createdAt"`
		LastSignInTime time.Time `json:"lastSignInTime"`
	} `json:"metadata"`
}

AuthEvent is the payload of a Firestore Auth event.

type FirebaseAuthFunction

type FirebaseAuthFunction func(ctx context.Context, event AuthEvent) error

FirebaseAuthFunction holds the function signature of a firebase auth triggered function

type FirebaseAuthFunctionBuilder

type FirebaseAuthFunctionBuilder struct {
	FunctionBuilder *FunctionBuilder

	Event   string
	Handler func(ctx context.Context, event AuthEvent) error
}

func (*FirebaseAuthFunctionBuilder) OnCreate

OnCreate is triggered when a user account is created.

func (*FirebaseAuthFunctionBuilder) OnDelete

OnDelete is triggered when a user account is deleted.

type FirestoreEvent

type FirestoreEvent struct {
	OldValue   FirestoreValue `json:"oldValue"`
	Value      FirestoreValue `json:"value"`
	UpdateMask struct {
		FieldPaths []string `json:"fieldPaths"`
	} `json:"updateMask"`
}

FirestoreEvent is the payload of a Firestore event.

type FirestoreFunction

type FirestoreFunction func(ctx context.Context, event FirestoreEvent) error

FirestoreFunction is the function signature of a firestore event triggered function

type FirestoreFunctionBuilder

type FirestoreFunctionBuilder struct {
	FunctionBuilder *FunctionBuilder

	Doc     string
	Event   string
	Handler func(ctx context.Context, event FirestoreEvent) error
}

FirestoreFunctionBuilder holds a FunctionBuilder and the firestore event entrypoint

func (*FirestoreFunctionBuilder) Document

Document sets the document for the function https://cloud.google.com/functions/docs/calling/cloud-firestore#specifying_the_document_path

func (*FirestoreFunctionBuilder) OnCreate

OnCreate creates a firestore function triggered on document creation

func (*FirestoreFunctionBuilder) OnDelete

OnDelete creates a firestore function triggered on document deletion

func (*FirestoreFunctionBuilder) OnUpdate

OnUpdate creates a firestore function triggered on a document update

func (*FirestoreFunctionBuilder) OnWrite

OnWrite creates a firestore function triggered on document write (creation, update, delete)

type FirestoreValue

type FirestoreValue struct {
	CreateTime time.Time   `json:"createTime"`
	Fields     interface{} `json:"fields"`
	Name       string      `json:"name"`
	UpdateTime time.Time   `json:"updateTime"`
}

FirestoreValue holds Firestore fields.

type FunctionBuilder

type FunctionBuilder struct {
	Retry       bool
	GCRegion    string
	RuntimeOpts RuntimeOptions
}

FunctionBuilder holds the deployment config for a function

func New

func New() *FunctionBuilder

New creates a new default FunctionBuilder

func (*FunctionBuilder) Auth

Auth creates a FirebaseAuthFunctionBuilder

func (*FunctionBuilder) Firestore

func (fb *FunctionBuilder) Firestore() *FirestoreFunctionBuilder

Firestore creates a FirestoreFunctionBuilder

func (*FunctionBuilder) OnRequest

func (fb *FunctionBuilder) OnRequest(fn func(w http.ResponseWriter, r *http.Request)) *HTTPFunctionBuilder

OnRequest creates a new http triggered function

func (*FunctionBuilder) PubSub

func (fb *FunctionBuilder) PubSub() *PubSubFunctionBuilder

PubSub creates a PubSubFunctionBuilder

func (*FunctionBuilder) Region

func (fb *FunctionBuilder) Region(region string) *FunctionBuilder

Region sets a region for a FunctionBuilder

func (*FunctionBuilder) RetryOnFailure

func (fb *FunctionBuilder) RetryOnFailure(retry bool) *FunctionBuilder

RetryOnFailure sets the retry option for deployment

func (*FunctionBuilder) RunWith

func (fb *FunctionBuilder) RunWith(opts RuntimeOptions) *FunctionBuilder

RunWith sets runtime options for the function

func (*FunctionBuilder) Storage

func (fb *FunctionBuilder) Storage() *StorageFunctionBuilder

Storage creates a StorageFunctionBuilder

func (*FunctionBuilder) String

func (fb *FunctionBuilder) String() string

type HTTPFunctionBuilder

type HTTPFunctionBuilder struct {
	FunctionBuilder *FunctionBuilder

	Handler func(w http.ResponseWriter, r *http.Request)
}

HTTPFunctionBuilder holds a FunctionBuilder and the http entry point

type PubSubFunction

type PubSubFunction func(ctx context.Context, event PubSubMessage) error

PubSubFunction holds the function signature of a pubsub event

type PubSubFunctionBuilder

type PubSubFunctionBuilder struct {
	FunctionBuilder *FunctionBuilder

	Event   string
	PSTopic string
	Handler func(ctx context.Context, event PubSubMessage) error
}

func (*PubSubFunctionBuilder) OnPublish

OnPublish is triggered when a message is published to the Cloud Pub/Sub topic that is specified when a function is deployed. Every message published to this topic will trigger function execution with message contents passed as input data.

func (*PubSubFunctionBuilder) Topic

Topic sets the trigger topic

type PubSubMessage

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

PubSubMessage is the payload of a Pub/Sub event. Please refer to the docs for additional information regarding Pub/Sub events.

type RuntimeOptions

type RuntimeOptions struct {
	Timeout int // number of seconds
	Memory  string
}

RuntimeOptions holds a timeout and memory option

type StorageEvent

type StorageEvent struct {
	Bucket         string    `json:"bucket"`
	Name           string    `json:"name"`
	Metageneration string    `json:"metageneration"`
	ResourceState  string    `json:"resourceState"`
	TimeCreated    time.Time `json:"timeCreated"`
	Updated        time.Time `json:"updated"`
}

StorageEvent is the payload of a GCS event. Please refer to the docs for additional information regarding GCS events.

type StorageFunction

type StorageFunction func(ctx context.Context, event StorageEvent) error

StorageFunction holds the function signature of storage event triggered function

type StorageFunctionBuilder

type StorageFunctionBuilder struct {
	FunctionBuilder *FunctionBuilder

	GCBucket string
	Event    string
	Handler  func(ctx context.Context, event StorageEvent) error
	// contains filtered or unexported fields
}

func (*StorageFunctionBuilder) Bucket

Bucket sets the trigger bucket

func (*StorageFunctionBuilder) Object

Object is a no op but without it the function definition would read something like Bucket("bucket").OnDelete() which sounds like a trigger for the event of bucket deletion when really it is for the deletion of a object in the bucket

func (*StorageFunctionBuilder) OnArchive

OnArchive is triggered when a live object is archived or deleted. Only triggered for versioning buckets. https://cloud.google.com/functions/docs/calling/storage#object_archive

func (*StorageFunctionBuilder) OnDelete

OnDelete is triggered when a live object is deleted. For versioning buckets, this is only sent when a version is permanently deleted (but not when an object is archived). For non-versioning buckets, this is sent when an object is deleted or overwritten. https://cloud.google.com/functions/docs/calling/storage#object_delete

func (*StorageFunctionBuilder) OnFinalize

OnFinalize is triggered when a new object is created (or an existing object is overwritten, and a new generation of that object is created) in the bucket. https://cloud.google.com/functions/docs/calling/storage#object_finalize

func (*StorageFunctionBuilder) OnMetadataUpdate

OnMetadataUpdate is triggered when an existing object's metadata changes https://cloud.google.com/functions/docs/calling/storage#object_metadata_update

Jump to

Keyboard shortcuts

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