Help us shape the future of Go! Take the 2026 Go Developer Survey

gcpevents

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gcpevents holds the Eventarc pieces shared by GCP emulators: path patterns and CloudEvents in binary content mode.

Index

Constants

View Source
const (
	// StorageTypePrefix prefixes Cloud Storage event types.
	StorageTypePrefix = "google.cloud.storage.object.v1."
	// FirestoreTypePrefix prefixes Firestore event types.
	FirestoreTypePrefix = "google.cloud.firestore.document.v1."
	// FirestoreWritten is the suffix matching created, updated and deleted.
	FirestoreWritten = "written"
)
View Source
const OperatorPathPattern = "match-path-pattern"

OperatorPathPattern is the EventFilter operator that selects path-pattern matching.

Variables

View Source
var ErrPattern = errors.New("invalid path pattern")

ErrPattern means a path pattern is malformed.

Functions

func CompilePathPattern

func CompilePathPattern(p string) (*regexp.Regexp, error)

CompilePathPattern turns an Eventarc path pattern into an anchored expression: "*" matches within one segment, "**" spans segments, "{name}" captures one segment and "{name=**}" several.

func MatchFilter

func MatchFilter(operator, want, got string) bool

MatchFilter reports whether got satisfies an event filter: exact equality, or a path pattern when operator is OperatorPathPattern.

Types

type CloudEvent

type CloudEvent struct {
	Extensions  map[string]string
	ID          string
	Source      string
	Type        string
	Subject     string
	Time        string
	ContentType string
	Data        []byte
}

CloudEvent is one event in binary content mode: attributes travel as ce-* headers, the payload as the body.

func FirestoreEvent

func FirestoreEvent(id, kind string, doc, old *firestorepb.Document, mask []string, t time.Time) (CloudEvent, error)

FirestoreEvent wraps a document change in a CloudEvent of type google.cloud.firestore.document.v1.<kind>. The payload is a google.events.cloud.firestore.v1.DocumentEventData message (value=1, old_value=2, update_mask=3), which Eventarc delivers as application/protobuf. The document name is projects/{p}/databases/{d}/documents/{path}.

func StorageEvent

func StorageEvent(id, kind, bucket, object string, data []byte, t time.Time) CloudEvent

StorageEvent wraps a Cloud Storage object resource (StorageObjectData JSON) in a CloudEvent of type google.cloud.storage.object.v1.<kind>.

func (CloudEvent) NewRequest

func (e CloudEvent) NewRequest(ctx context.Context, url string) (*http.Request, error)

NewRequest builds the POST that delivers e to url.

Jump to

Keyboard shortcuts

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