Documentation
¶
Index ¶
- Constants
- Variables
- func IsCallbackPath(path string) bool
- type ConfigProvider
- type Endpoints
- type Handler
- func (h *Handler) API() workflowspb.WorkflowsServer
- func (h *Handler) Addr() string
- func (h *Handler) ExecutionsAPI() executionspb.ExecutionsServer
- func (h *Handler) ExtractOperation(*echo.Context) string
- func (h *Handler) ExtractResource(*echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- type InMemoryBackend
- func (b *InMemoryBackend) CallbackHandler() http.Handler
- func (b *InMemoryBackend) CancelExecution(in *executionspb.CancelExecutionRequest) (*executionspb.Execution, error)
- func (b *InMemoryBackend) Close()
- func (b *InMemoryBackend) CloseIdleConnections()
- func (b *InMemoryBackend) CreateExecution(in *executionspb.CreateExecutionRequest) (*executionspb.Execution, error)
- func (b *InMemoryBackend) CreateWorkflow(in *workflowspb.CreateWorkflowRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) DeleteWorkflow(in *workflowspb.DeleteWorkflowRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) GetExecution(in *executionspb.GetExecutionRequest) (*executionspb.Execution, error)
- func (b *InMemoryBackend) GetLocation(name string) (*location.Location, error)
- func (b *InMemoryBackend) GetWorkflow(in *workflowspb.GetWorkflowRequest) (*workflowspb.Workflow, error)
- func (b *InMemoryBackend) ListExecutions(in *executionspb.ListExecutionsRequest) (*executionspb.ListExecutionsResponse, error)
- func (b *InMemoryBackend) ListLocations(in *location.ListLocationsRequest) (*location.ListLocationsResponse, error)
- func (b *InMemoryBackend) ListWorkflowRevisions(in *workflowspb.ListWorkflowRevisionsRequest) (*workflowspb.ListWorkflowRevisionsResponse, error)
- func (b *InMemoryBackend) ListWorkflows(in *workflowspb.ListWorkflowsRequest) (*workflowspb.ListWorkflowsResponse, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetClock(c wfinterp.Clock)
- func (b *InMemoryBackend) SetEndpoints(e Endpoints)
- func (b *InMemoryBackend) SetLogSink(s gcpserve.LogSink)
- func (b *InMemoryBackend) SetPushBase(base string)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartExecution(_ context.Context, workflow string, argument []byte) error
- func (b *InMemoryBackend) UpdateWorkflow(in *workflowspb.UpdateWorkflowRequest) (*longrunningpb.Operation, error)
- func (b *InMemoryBackend) WorkflowExists(name string) bool
- type Provider
- type Settings
Constants ¶
const DefaultPort = 8139
DefaultPort is the dedicated gRPC and REST listener's default TCP port.
Variables ¶
var ErrNilAppContext = errors.New("gcpworkflows: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
Functions ¶
func IsCallbackPath ¶
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 ¶
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 ¶
func (h *Handler) API() workflowspb.WorkflowsServer
API exposes the Workflows service for in-process callers.
func (*Handler) ExecutionsAPI ¶
func (h *Handler) ExecutionsAPI() executionspb.ExecutionsServer
ExecutionsAPI exposes the Executions service for in-process callers.
func (*Handler) ExtractOperation ¶
ExtractOperation is unused: requests never reach the shared router.
func (*Handler) ExtractResource ¶
ExtractResource is unused: requests never reach the shared router.
func (*Handler) GetSupportedOperations ¶
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 ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: Workflows runs on its own listener.
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 ¶
func (b *InMemoryBackend) CancelExecution(in *executionspb.CancelExecutionRequest) (*executionspb.Execution, error)
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 ¶
func (b *InMemoryBackend) CreateExecution(in *executionspb.CreateExecutionRequest) (*executionspb.Execution, error)
CreateExecution starts an execution of the latest revision of a workflow.
func (*InMemoryBackend) CreateWorkflow ¶
func (b *InMemoryBackend) CreateWorkflow(in *workflowspb.CreateWorkflowRequest) (*longrunningpb.Operation, error)
CreateWorkflow validates and compiles the source, then stores the workflow; the operation is already done.
func (*InMemoryBackend) DeleteWorkflow ¶
func (b *InMemoryBackend) DeleteWorkflow(in *workflowspb.DeleteWorkflowRequest) (*longrunningpb.Operation, error)
DeleteWorkflow removes a workflow with its revisions and executions.
func (*InMemoryBackend) GetExecution ¶
func (b *InMemoryBackend) GetExecution(in *executionspb.GetExecutionRequest) (*executionspb.Execution, error)
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 ¶
func (b *InMemoryBackend) GetWorkflow(in *workflowspb.GetWorkflowRequest) (*workflowspb.Workflow, error)
GetWorkflow returns the latest revision of a workflow, or the revision named by revision_id.
func (*InMemoryBackend) ListExecutions ¶
func (b *InMemoryBackend) ListExecutions( in *executionspb.ListExecutionsRequest, ) (*executionspb.ListExecutionsResponse, error)
ListExecutions lists the executions of a workflow, newest first by default; the view defaults to BASIC.
func (*InMemoryBackend) ListLocations ¶
func (b *InMemoryBackend) ListLocations(in *location.ListLocationsRequest) (*location.ListLocationsResponse, error)
ListLocations lists the Workflows locations.
func (*InMemoryBackend) ListWorkflowRevisions ¶
func (b *InMemoryBackend) ListWorkflowRevisions( in *workflowspb.ListWorkflowRevisionsRequest, ) (*workflowspb.ListWorkflowRevisionsResponse, error)
ListWorkflowRevisions lists the revisions of a workflow, newest first.
func (*InMemoryBackend) ListWorkflows ¶
func (b *InMemoryBackend) ListWorkflows( in *workflowspb.ListWorkflowsRequest, ) (*workflowspb.ListWorkflowsResponse, error)
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 ¶
StartExecution runs a workflow with a JSON argument; Eventarc uses it for workflow destinations.
func (*InMemoryBackend) UpdateWorkflow ¶
func (b *InMemoryBackend) UpdateWorkflow(in *workflowspb.UpdateWorkflowRequest) (*longrunningpb.Operation, error)
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 ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the port is bound in StartWorker.
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.