Documentation
¶
Overview ¶
Package gcpevents holds the Eventarc pieces shared by GCP emulators: path patterns and CloudEvents in binary content mode.
Index ¶
Constants ¶
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" )
const OperatorPathPattern = "match-path-pattern"
OperatorPathPattern is the EventFilter operator that selects path-pattern matching.
Variables ¶
var ErrPattern = errors.New("invalid path pattern")
ErrPattern means a path pattern is malformed.
Functions ¶
func CompilePathPattern ¶
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 ¶
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 ¶
NewRequest builds the POST that delivers e to url.