package metadata

import "cloud.google.com/go/functions/metadata"

Package metadata provides methods for creating and accessing context.Context objects with Google Cloud Functions metadata.

Index

Functions

func NewContext

func NewContext(ctx context.Context, m Metadata) context.Context

NewContext returns a new Context carrying m.

Types

type Metadata

type Metadata struct {
	// EventID is a unique ID for the event. For example: "70172329041928".
	EventID string `json:"eventId"`
	// Timestamp is the date/time this event was created.
	Timestamp time.Time `json:"timestamp"`
	// EventType is the type of the event. For example: "google.pubsub.topic.publish".
	EventType string `json:"eventType"`
	// Resource is the resource that triggered the event.
	Resource Resource `json:"resource"`
}

Metadata holds Google Cloud Functions metadata.

func FromContext

func FromContext(ctx context.Context) (Metadata, bool)

FromContext extracts the Metadata from the Context, if present.

type Resource

type Resource struct {
	// Service is the service that triggered the event.
	Service string `json:"service"`
	// Name is the name associated with the event.
	Name string `json:"name"`
	// Type is the type of event.
	Type string `json:"type"`
}

Resource holds Google Cloud Functions resource metadata. Resource values are dependent on the event type they're from.

Source Files

metadata.go

Version
v0.30.0
Published
Oct 8, 2018
Platform
js/wasm
Imports
2 packages
Last checked
24 minutes ago

Tools for package owners.