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

gcpworkflows

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: 50 Imported by: 0

README

Workflows

Parity grade: B · SDK cloud.google.com/go/workflows@v1.21.0 · last audited 2026-10-25 (d02c76d92)

Coverage

Metric Value
PARITY entries audited 13 (8 ok, 5 partial)
Feature families 12 (2 ok, 10 partial)
Known gaps 8
Deferred items 0
Resource leaks clean
Known gaps
  • execution_history_level, execution step history (Executions step entries) and automatic call logging are stored but not produced; CMEK (crypto_key_name) is stored, not used.
  • Quotas are only partly modelled: 100000 steps per execution and a call depth of 20 are enforced; the 512 KB result/argument rules, concurrent execution limits, QUEUED state and the 1 year execution timeout are not.
  • Variable use is not statically checked: undefined variables, writes to non-shared parent variables inside parallel steps and loop-variable scope leaks fail at run time instead of at deployment.
  • experimental.executions.run/map, the in() function form and non-UTF-8 charsets are not implemented; get_type value names, the exact text of runtime error messages and deployment error messages, and the code of the failed CreateWorkflow operation were chosen without a production reference.
  • Only the listed googleapis.* connectors exist; other connectors, connector retry/long-running-operation polling helpers and calls to *.googleapis.com hosts (which would leave the emulator) are not rewritten.
  • Operations are recorded already finished: no CREATING state, and CancelOperation has no effect.
  • ListWorkflows and ListExecutions reject unsupported filter expressions instead of evaluating the full AIP-160 grammar; UpdateWorkflow with an empty mask updates only the fields present.
  • Callback endpoints and in-flight executions do not survive a restore, and a callback URL is bound to the listener port of the run that created it.

More

Documentation

Index

Constants

View Source
const DefaultPort = 8139

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

Variables

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

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

Functions

func IsCallbackPath

func IsCallbackPath(path string) bool

IsCallbackPath reports whether path addresses a callback endpoint.

Types

type ConfigProvider

type ConfigProvider interface {
	GetGCPWorkflowsSettings() Settings
}

ConfigProvider extracts Workflows configuration from the AppContext Config.

type Endpoints

type Endpoints interface {
	BaseURL(service string) string
}

Endpoints resolves the base URL (scheme and host:port) of another emulator's REST API for connectors.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	Port int
	// contains filtered or unexported fields
}

Handler serves the Workflows 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 Workflows service for in-process callers.

func (*Handler) Addr

func (h *Handler) Addr() string

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

func (*Handler) ExecutionsAPI

func (h *Handler) ExecutionsAPI() executionspb.ExecutionsServer

ExecutionsAPI exposes the Executions service for in-process callers.

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: Workflows 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 Workflows state under one lock.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates an empty backend.

func (*InMemoryBackend) CallbackHandler

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

CallbackHandler serves the endpoints events.create_callback_endpoint hands out.

func (*InMemoryBackend) CancelExecution

CancelExecution cancels an active execution.

func (*InMemoryBackend) Close

func (b *InMemoryBackend) Close()

Close stops all running executions; the backend is unusable afterwards.

func (*InMemoryBackend) CloseIdleConnections

func (b *InMemoryBackend) CloseIdleConnections()

CloseIdleConnections releases pooled outbound connections.

func (*InMemoryBackend) CreateExecution

CreateExecution starts an execution of the latest revision of a workflow.

func (*InMemoryBackend) CreateWorkflow

CreateWorkflow validates and compiles the source, then stores the workflow; the operation is already done.

func (*InMemoryBackend) DeleteWorkflow

DeleteWorkflow removes a workflow with its revisions and executions.

func (*InMemoryBackend) GetExecution

GetExecution returns an execution; the view defaults to FULL.

func (*InMemoryBackend) GetLocation

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

GetLocation returns a Workflows location.

func (*InMemoryBackend) GetWorkflow

GetWorkflow returns the latest revision of a workflow, or the revision named by revision_id.

func (*InMemoryBackend) ListExecutions

ListExecutions lists the executions of a workflow, newest first by default; the view defaults to BASIC.

func (*InMemoryBackend) ListLocations

ListLocations lists the Workflows locations.

func (*InMemoryBackend) ListWorkflowRevisions

ListWorkflowRevisions lists the revisions of a workflow, newest first.

func (*InMemoryBackend) ListWorkflows

ListWorkflows lists the workflows of a location, or of every location for "-".

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears all state and cancels running executions.

func (*InMemoryBackend) Restore

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

Restore loads a snapshot, replacing all state; executions that were running become FAILED.

func (*InMemoryBackend) SetClock

func (b *InMemoryBackend) SetClock(c wfinterp.Clock)

SetClock replaces the clock sys.sleep, retries and timestamps use; tests pass a fake.

func (*InMemoryBackend) SetEndpoints

func (b *InMemoryBackend) SetEndpoints(e Endpoints)

SetEndpoints connects googleapis.* connectors to the other emulators' REST APIs.

func (*InMemoryBackend) SetLogSink

func (b *InMemoryBackend) SetLogSink(s gcpserve.LogSink)

SetLogSink sends sys.log output to Cloud Logging; nil disables it.

func (*InMemoryBackend) SetPushBase

func (b *InMemoryBackend) SetPushBase(base string)

SetPushBase records the base URL (scheme and host:port) callback endpoints are served from.

func (*InMemoryBackend) Snapshot

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

Snapshot serialises workflows with their revisions, executions and operations.

func (*InMemoryBackend) StartExecution

func (b *InMemoryBackend) StartExecution(_ context.Context, workflow string, argument []byte) error

StartExecution runs a workflow with a JSON argument; Eventarc uses it for workflow destinations.

func (*InMemoryBackend) UpdateWorkflow

UpdateWorkflow updates the masked fields; changing the source or service account creates a revision.

func (*InMemoryBackend) WorkflowExists

func (b *InMemoryBackend) WorkflowExists(name string) bool

WorkflowExists reports whether a workflow exists.

type Provider

type Provider struct{}

Provider implements service.Provider for Google Cloud Workflows. 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 Settings

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

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

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider is available.

Jump to

Keyboard shortcuts

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