gcpeventarc

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 64 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Eventarc

Parity grade: B · SDK cloud.google.com/go/eventarc@v1.26.0 · last audited 2026-11-05 (b1c140fda)

Coverage

Metric Value
PARITY entries audited 47 (27 ok, 20 partial)
Feature families 13 (9 ok, 4 partial)
Known gaps 3
Deferred items 0
Resource leaks clean
Known gaps
  • Audit logs: Data Access records are emitted unconditionally (honouring audit configs is IAM policy evaluation, out of scope), the principal is the fixed gcpaudit.DefaultPrincipal, Cloud Build, Cloud Run, Pub/Sub, KMS and the other emulated services record nothing (Artifact Registry records repository and artifact writes, not reads or Docker data-plane calls).
  • Advanced: Publisher avro_message is UNIMPLEMENTED (publisher.pb.go names the CloudEvents Avro format, but the exact record schema and union order could not be read verbatim from the spec page, and Avro binary needs them exact); input_payload_format and output_payload_format are recorded but data is always JSON, and toDestinationPayloadFormat and toCloudEventJsonWithPayloadFormat are identity, because avro and protobuf payloads need those schemas; an organization subscription covers every project under the single emulated organization (a project Resource Manager does not know is delivered).
  • event_data_content_type application/protobuf is honoured only for Firestore events; Cloud Storage and Pub/Sub events are always JSON.

More

Documentation

Index

Constants

View Source
const DefaultPort = 8138

DefaultPort is the dedicated gRPC and REST listener's default TCP port.

Variables

View Source
var ErrNilAppContext = errors.New("gcpeventarc: nil app context")

ErrNilAppContext is returned when Init is called with a nil AppContext.

Functions

This section is empty.

Types

type AfterFunc

type AfterFunc func(d time.Duration, f func()) (stop func())

AfterFunc runs f once after d and returns a function that cancels it.

type Buckets

type Buckets interface {
	BucketLocation(bucket string) (string, bool)
	BucketProject(bucket string) (string, bool)
}

Buckets resolves the location of a Cloud Storage bucket.

type Clusters

type Clusters interface {
	ClusterExists(name string) bool
}

Clusters checks the GKE clusters of GKE destinations.

type ConfigProvider

type ConfigProvider interface {
	GetGCPEventarcSettings() Settings
}

ConfigProvider extracts Eventarc configuration from the AppContext Config.

type DocumentEvent

type DocumentEvent struct {
	Time       time.Time
	Old        *firestorepb.Document
	New        *firestorepb.Document
	Kind       string
	UpdateMask []string
}

DocumentEvent is a committed Firestore document change; Kind is created, updated or deleted.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	Port int
	// contains filtered or unexported fields
}

Handler serves the Eventarc API on a dedicated gRPC and REST listener.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler creates a Handler; callers override Port from Settings.

func (*Handler) API

API exposes the Eventarc service for in-process callers (dashboard proxy).

func (*Handler) Addr

func (h *Handler) Addr() string

Addr returns the bound listener address, or "" before StartWorker.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(*echo.Context) string

ExtractOperation is unused: requests never reach the shared router.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(*echo.Context) string

ExtractResource is unused: requests never reach the shared router.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists the supported gRPC methods.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns a 404 handler; the real API is on the dedicated port.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority is irrelevant because RouteMatcher never matches.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: Eventarc runs on its own listener.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown stops the listener, forcing a close after a short grace period.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker binds the dedicated listener synchronously so a port conflict is returned to the caller.

type InMemoryBackend

type InMemoryBackend struct {
	// contains filtered or unexported fields
}

InMemoryBackend holds all Eventarc state under one lock.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates an empty backend.

func (*InMemoryBackend) Close

func (b *InMemoryBackend) Close()

Close stops pending timers.

func (*InMemoryBackend) CloseIdleConnections

func (b *InMemoryBackend) CloseIdleConnections()

CloseIdleConnections releases pooled delivery connections.

func (*InMemoryBackend) CreateChannel

CreateChannel creates a third-party channel with its Pub/Sub topic; it starts PENDING until a connection presents its activation token.

func (*InMemoryBackend) CreateChannelConnection

CreateChannelConnection activates a channel by presenting its activation token.

func (*InMemoryBackend) CreateTrigger

CreateTrigger creates a trigger and its transport; the returned operation is already done.

func (*InMemoryBackend) DeleteChannel

DeleteChannel removes a channel, its topic and its connections; triggers still on the channel block it.

func (*InMemoryBackend) DeleteChannelConnection

DeleteChannelConnection removes a connection; its channel goes INACTIVE.

func (*InMemoryBackend) DeleteTrigger

DeleteTrigger removes a trigger and the transport resources it owns.

func (*InMemoryBackend) GetChannel

func (b *InMemoryBackend) GetChannel(name string) (*eventarcpb.Channel, error)

GetChannel returns a channel.

func (*InMemoryBackend) GetChannelConnection

func (b *InMemoryBackend) GetChannelConnection(name string) (*eventarcpb.ChannelConnection, error)

GetChannelConnection returns a channel connection.

func (*InMemoryBackend) GetGoogleChannelConfig

func (b *InMemoryBackend) GetGoogleChannelConfig(name string) (*eventarcpb.GoogleChannelConfig, error)

GetGoogleChannelConfig returns the location's config, an empty one until it is first updated.

func (*InMemoryBackend) GetIamPolicy

func (b *InMemoryBackend) GetIamPolicy(resource string, version int32) (*iampb.Policy, error)

GetIamPolicy returns the policy of a trigger or channel at the requested version.

func (*InMemoryBackend) GetLocation

func (b *InMemoryBackend) GetLocation(name string) (*location.Location, error)

GetLocation describes one Eventarc location.

func (*InMemoryBackend) GetProvider

func (b *InMemoryBackend) GetProvider(name string) (*eventarcpb.Provider, error)

GetProvider returns an event provider of the catalog.

func (*InMemoryBackend) GetTrigger

func (b *InMemoryBackend) GetTrigger(name string) (*eventarcpb.Trigger, error)

GetTrigger returns a trigger.

func (*InMemoryBackend) HandleDocumentEvent

func (b *InMemoryBackend) HandleDocumentEvent(ev DocumentEvent)

HandleDocumentEvent delivers a Firestore document change to the created/updated/deleted trigger of its kind and to written triggers whose database, namespace and document filters it satisfies.

func (*InMemoryBackend) HandleLogEntry

func (b *InMemoryBackend) HandleLogEntry(e *loggingpb.LogEntry)

HandleLogEntry delivers a Cloud Audit Logs entry (protoPayload AuditLog) to the triggers on google.cloud.audit.log.v1.written whose serviceName, methodName and resourceName filters it satisfies. Entries without an AuditLog payload are ignored.

func (*InMemoryBackend) HandleStorageEvent

func (b *InMemoryBackend) HandleStorageEvent(ev StorageEvent)

HandleStorageEvent publishes ev to the transport topic of every trigger whose filters it satisfies.

func (*InMemoryBackend) ListChannelConnections

ListChannelConnections lists the connections of a location, or of every location for "-".

func (*InMemoryBackend) ListChannels

ListChannels lists the channels of a location, or of every location for "-".

func (*InMemoryBackend) ListLocations

ListLocations lists the Eventarc locations.

func (*InMemoryBackend) ListMessageBusEnrollments

ListMessageBusEnrollments lists the names of the enrollments on a message bus.

func (*InMemoryBackend) ListProviders

ListProviders lists the event providers; filter matches a substring of name or display_name.

func (*InMemoryBackend) ListTriggers

ListTriggers lists the triggers of a location, or of every location for "-".

func (*InMemoryBackend) PublishToBus

func (b *InMemoryBackend) PublishToBus(bus string, event map[string]any) error

PublishToBus routes a CloudEvent (as a JSON object) through the enrollments of a message bus.

func (*InMemoryBackend) PublishToChannel

func (b *InMemoryBackend) PublishToChannel(channel string, events []map[string]any) error

PublishToChannel delivers CloudEvents to the triggers attached to a channel.

func (*InMemoryBackend) PublishToChannelConnection

func (b *InMemoryBackend) PublishToChannelConnection(conn string, events []map[string]any) error

PublishToChannelConnection delivers events published through a channel connection to its channel.

func (*InMemoryBackend) PushHandler

func (b *InMemoryBackend) PushHandler() http.Handler

PushHandler receives the Pub/Sub push requests of trigger subscriptions and forwards each message as a CloudEvent to the trigger's destination. A non-2xx reply makes Pub/Sub redeliver with backoff.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all state.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads a snapshot, replacing all state.

func (*InMemoryBackend) SetAfterFunc

func (b *InMemoryBackend) SetAfterFunc(f AfterFunc)

SetAfterFunc replaces the timer used for operation completion and Advanced retries (tests inject a fake).

func (*InMemoryBackend) SetIamPolicy

func (b *InMemoryBackend) SetIamPolicy(in *iampb.SetIamPolicyRequest) (*iampb.Policy, error)

SetIamPolicy replaces a policy; a stale etag aborts the call.

func (*InMemoryBackend) SetKeyChecker

func (b *InMemoryBackend) SetKeyChecker(c cmek.Checker)

SetKeyChecker validates crypto_key_name against Cloud KMS; nil disables validation.

func (*InMemoryBackend) SetOperationDelay

func (b *InMemoryBackend) SetOperationDelay(d time.Duration)

SetOperationDelay sets how long new long-running operations stay not done; zero finishes them at once.

func (*InMemoryBackend) SetPushBase

func (b *InMemoryBackend) SetPushBase(base string)

SetPushBase records the base URL (scheme and host:port) the Pub/Sub emulator pushes events to.

func (*InMemoryBackend) SetRetryBackoff

func (b *InMemoryBackend) SetRetryBackoff(minimum, maximum time.Duration)

SetRetryBackoff sets the minimum and maximum redelivery backoff of triggers created from now on.

func (*InMemoryBackend) SetServices

func (b *InMemoryBackend) SetServices(s Services)

SetServices connects Eventarc to the other emulators.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises triggers, channels, connections, channel configs and operations.

func (*InMemoryBackend) TestIamPermissions

TestIamPermissions reports the requested Eventarc permissions as granted: the emulator authorises all callers.

func (*InMemoryBackend) UpdateChannel

UpdateChannel updates crypto_key_name and labels.

func (*InMemoryBackend) UpdateGoogleChannelConfig

UpdateGoogleChannelConfig sets crypto_key_name and labels.

func (*InMemoryBackend) UpdateTrigger

UpdateTrigger updates the masked fields of a trigger.

type Organization

type Organization interface {
	ProjectInOrganization(project string) (in, known bool)
}

Organization places projects under the organization an organization subscription covers.

type Provider

type Provider struct{}

Provider implements service.Provider for Google Cloud Eventarc. It serves gRPC and REST on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.

func (*Provider) Init

Init creates the backend and handler; the port is bound in StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type PubSub

type PubSub interface {
	CreateTopic(in *pubsubpb.Topic) (*pubsubpb.Topic, error)
	GetTopic(name string) (*pubsubpb.Topic, error)
	DeleteTopic(name string) error
	CreateSubscription(in *pubsubpb.Subscription) (*pubsubpb.Subscription, error)
	DeleteSubscription(name string) error
	UpdateSubscription(req *pubsubpb.UpdateSubscriptionRequest) (*pubsubpb.Subscription, error)
	Publish(req *pubsubpb.PublishRequest) ([]string, error)
}

PubSub is the slice of the Pub/Sub emulator Eventarc uses as its event transport.

type Services

type Services struct {
	PubSub    PubSub
	Targets   Targets
	Workflows Workflows
	Buckets   Buckets
	Org       Organization
	Clusters  Clusters
}

Services are the emulators Eventarc reads from and delivers to; absent ones stay nil.

type Settings

type Settings struct {
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 184-byte string literal not displayed */
}

Settings holds service-level configuration, embedded in the root CLI as CLI.GCPEventarc.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider is available.

type StorageEvent

type StorageEvent struct {
	Time   time.Time
	Type   string
	Bucket string
	Name   string
	// Project owns the bucket; empty when unknown.
	Project string
	Data    []byte
}

StorageEvent is a Cloud Storage object change. Type is the event type suffix (finalized, deleted, archived or metadataUpdated) and Data the object resource JSON.

type Targets

type Targets interface {
	ServiceURL(project, region, service string) (string, error)
}

Targets resolves the serving URL of a Cloud Run service, which also covers the service behind a Cloud Functions (2nd gen) function of the same id.

type Workflows

type Workflows interface {
	WorkflowExists(name string) bool
	StartExecution(ctx context.Context, workflow string, argument []byte) error
}

Workflows starts workflow executions for workflow destinations.

Jump to

Keyboard shortcuts

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