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

gcpeventarc

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 42 Imported by: 0

README

Eventarc

Parity grade: B · SDK cloud.google.com/go/eventarc@v1.26.0 · last audited 2026-10-25 (5964f2cd3)

Coverage

Metric Value
PARITY entries audited 24 (17 ok, 7 partial)
Feature families 8 (5 ok, 3 partial)
Known gaps 10
Deferred items 0
Resource leaks clean
Known gaps
  • Cloud Audit Logs events (google.cloud.audit.log.v1.written) are not delivered: the Logging emulator keeps no audit log entries to match. Triggers for them are rejected.
  • Only Pub/Sub and Cloud Storage events exist; every other Google source (Firebase, Cloud Build, Firestore, Artifact Registry, direct events of other services) and third-party providers are absent from ListProviders, and triggers on a channel are stored but receive no events.
  • Triggers cannot target GKE (not emulated); Cloud Functions are reached through the Cloud Run destination, a trigger cannot set cloud_function (the API forbids it).
  • MessageBus, Enrollment, Pipeline, GoogleApiSource, LoggingConfig and Eventarc Advanced are UNIMPLEMENTED.
  • retry_policy.max_attempts is stored but not enforced, and there is no dead-letter handling; delivery retries until the subscription's 24 hour retention expires.
  • network_config, event_data_content_type application/protobuf, CMEK (crypto_key_name) and satisfies_pzs are not honoured; trigger conditions are always empty.
  • A Cloud Run service need not exist when a trigger is created; an unresolved service only fails deliveries (and is retried). Region and location rules (global triggers, storage bucket region match) are not enforced.
  • Operations are recorded already finished: no CREATING state, and CancelOperation has no effect.
  • After a restore the transport subscriptions keep the push endpoint of the run that created them; a changed --gcp-eventarc-port needs the triggers recreated.
  • Trigger and channel id rules, the ABORTED etag code, FAILED_PRECONDITION for a missing user topic and INVALID_ARGUMENT for a bad channel activation token were chosen without a production reference.

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 ConfigProvider

type ConfigProvider interface {
	GetGCPEventarcSettings() Settings
}

ConfigProvider extracts Eventarc configuration from the AppContext Config.

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) 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) 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) 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) 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) SetIamPolicy

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

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

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 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
	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
}

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
	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