Documentation
¶
Overview ¶
Package types defines interfaces for activities that can be consumed by recipe-worker
Index ¶
- Constants
- func Clear()
- func CommandMain(op RegisterableOp)
- func DecodeHookMapDecoder(from reflect.Type, to reflect.Type, data any) (any, error)
- func DecodeWithJsonTags[T any](data map[string]interface{}, input *T) error
- func Register(ops ...RegisterableOp)
- func Replace(ops ...RegisterableOp)
- func RunAsCommand(op RegisterableOp) int
- func Size() int
- func SuspendExecution(deps OpDependencies, patch execution.Requirements) error
- type ActivityHandlerV2
- type GitExecutionContext
- type HasManagmentService
- type JobTool
- type ManagementService
- type MapDecoder
- type OpBuilder
- type OpDependencies
- type OpDependenciesBuilder
- func (b *OpDependenciesBuilder) Build() OpDependencies
- func (b *OpDependenciesBuilder) WithArtifacts(initialArtifacts []jobdb.Artifact) *OpDependenciesBuilder
- func (b *OpDependenciesBuilder) WithCurrentJobContext(ctx jobcontext.Current) *OpDependenciesBuilder
- func (b *OpDependenciesBuilder) WithDatabase(db *gorm.DB) *OpDependenciesBuilder
- func (b *OpDependenciesBuilder) WithGitContext(ctx GitExecutionContext) *OpDependenciesBuilder
- func (b *OpDependenciesBuilder) WithJobTool(jt JobTool) *OpDependenciesBuilder
- func (b *OpDependenciesBuilder) WithOperationPathRuntime(runtime OperationPathRuntime) *OpDependenciesBuilder
- func (b *OpDependenciesBuilder) WithOperationPaths(paths OperationPaths) *OpDependenciesBuilder
- func (b *OpDependenciesBuilder) WithProtectedEnv(env map[string]string) *OpDependenciesBuilder
- func (b *OpDependenciesBuilder) WithTaskContext(tc jobworkflow.TaskContext) *OpDependenciesBuilder
- func (b *OpDependenciesBuilder) WithWorkflowControl(wc workflowctl.WorkflowControl) *OpDependenciesBuilder
- func (b *OpDependenciesBuilder) WithWorktreePath(path string) *OpDependenciesBuilder
- type OpExecutor
- type OpInputType
- type OpMetadata
- type OpOutputType
- type OperationPathProvider
- type OperationPathRuntime
- type OperationPathRuntimeProvider
- type OperationPathTransformRequest
- type OperationPathTransformResult
- type OperationPathTransformer
- type OperationPathViews
- type OperationPaths
- type RawMessageOrStruct
- type RegisterableOp
- func Get(name string) (RegisterableOp, bool)
- func List() []RegisterableOp
- func NewActivityMappedOpV2[In any, Out any](metadata OpMetadata, handler ActivityHandlerV2[In, Out]) RegisterableOp
- func NewActivityMappedOpWithProviderV2[In any, Out any](metadata OpMetadata, handler ActivityHandlerV2[In, Out], ...) RegisterableOp
- type RequiredMount
- type RequiredPort
- type Route
- type SSEEvent
- type SSEManager
- type ServiceDependencies2
- type ServiceDepsBuilder
- func (b *ServiceDepsBuilder) Build() ServiceDependencies2
- func (b *ServiceDepsBuilder) WithDatabase(db *gorm.DB) *ServiceDepsBuilder
- func (b *ServiceDepsBuilder) WithSSEManager(mgr SSEManager) *ServiceDepsBuilder
- func (b *ServiceDepsBuilder) WithWorkflowControl(ctl workflowctl.WorkflowControl) *ServiceDepsBuilder
- type Step
- type TaskBasedJobTool
- type TaskStep
Constants ¶
const ( MountModeReadOnly = "ro" MountModeReadWrite = "rw" )
Variables ¶
This section is empty.
Functions ¶
func CommandMain ¶
func CommandMain(op RegisterableOp)
CommandMain executes a single-step RegisterableOp using the extension process contract.
func DecodeHookMapDecoder ¶
func DecodeWithJsonTags ¶
func Register ¶
func Register(ops ...RegisterableOp)
Register adds a new operatio(s)) to the registry
func Replace ¶
func Replace(ops ...RegisterableOp)
Replace atomically swaps the registry contents with the provided operations.
func RunAsCommand ¶
func RunAsCommand(op RegisterableOp) int
RunAsCommand executes a single-step RegisterableOp using JSON stdin/stdout.
func SuspendExecution ¶ added in v0.0.52
func SuspendExecution(deps OpDependencies, patch execution.Requirements) error
SuspendExecution attaches a continuation directive to the durable activity result. Return normally after requesting it; dependent recipe work resumes only after a new execution invocation. It does not migrate in-memory work.
Types ¶
type ActivityHandlerV2 ¶
type ActivityHandlerV2[In OpInputType, Out OpOutputType] func(deps OpDependencies, ctx context.Context, in In) (Out, error)
ActivityHandlerV2 defines the signature for activity handlers that accept an invocation descriptor.
type GitExecutionContext ¶
type GitExecutionContext struct {
BaseRepo string `json:"base_repo,omitempty"`
BaseRef string `json:"base_ref,omitempty"`
ResolvedBaseHash string `json:"resolved_base_hash,omitempty"`
RecipeSourceRepo string `json:"recipe_source_repo,omitempty"`
RecipeSourceRef string `json:"recipe_source_ref,omitempty"`
PersistHash string `json:"persist_hash,omitempty"`
ParentHash string `json:"parent_hash,omitempty"`
CellName string `json:"cell_name,omitempty"`
GitAuthor string `json:"git_author,omitempty"`
NodePath string `json:"node_path,omitempty"`
InvokeSeq int64 `json:"invoke_seq,omitempty"`
InvokeHash string `json:"invoke_hash,omitempty"`
WorktreePath string `json:"worktree_path,omitempty"`
}
GitExecutionContext exposes the current execution workspace and git metadata to ops without requiring user-facing inputs to mirror internal runtime state.
type HasManagmentService ¶
type HasManagmentService interface {
GetManagementService() ManagementService
}
type JobTool ¶
JobTool provides a way to influence the current jobs operation. It is separate from workflowcontrol, which is about running jobs independent of this jobs context.
type ManagementService ¶
type ManagementService interface {
// GetRoutes returns HTTP routes this service provides
GetRoutes() []Route
// Initialize with injected dependencies
Initialize(deps ServiceDependencies2) error
Close()
}
ManagementService provides HTTP endpoints for managing input requests
type MapDecoder ¶
type OpBuilder ¶
type OpBuilder interface {
WithType(t string) OpBuilder
WithDescription(desc string) OpBuilder
WithVersion(ver string) OpBuilder
WithDefaultTimeout(d time.Duration) OpBuilder
WithAcceptsArtifacts(accept bool) OpBuilder
AddStep(name string, step Step) OpBuilder
WithManagementService(svc ManagementService) OpBuilder
Build() (RegisterableOp, error)
BuildOrPanic() RegisterableOp
}
OpBuilder builds a multi-step RegisterableOp.
type OpDependencies ¶
type OpDependencies interface {
Database() *gorm.DB
WorkflowControl() workflowctl.WorkflowControl
GetInputArtifacts() []jobdb.Artifact
AddOutputArtifact(jobdb.Artifact) error
AddExternalArtifact(name string, url string, expand bool) error
GetOutputArtifacts() []jobdb.Artifact
GetExternalArtifacts() map[string]recipeartifacts.Ref
WorktreePath() string
GitContext() GitExecutionContext
CurrentJobContext() jobcontext.Current
ProtectedEnv() map[string]string
JobTool() JobTool
FindArtifact(key jobdb.ArtifactKey) (jobdb.Artifact, error)
SetNextTaskType(taskType string)
}
type OpDependenciesBuilder ¶
type OpDependenciesBuilder struct {
// contains filtered or unexported fields
}
func NewOpDependenciesBuilder ¶
func NewOpDependenciesBuilder() *OpDependenciesBuilder
NewOpDependenciesBuilder creates a new, empty builder instance.
func (*OpDependenciesBuilder) Build ¶
func (b *OpDependenciesBuilder) Build() OpDependencies
func (*OpDependenciesBuilder) WithArtifacts ¶
func (b *OpDependenciesBuilder) WithArtifacts(initialArtifacts []jobdb.Artifact) *OpDependenciesBuilder
func (*OpDependenciesBuilder) WithCurrentJobContext ¶ added in v0.0.42
func (b *OpDependenciesBuilder) WithCurrentJobContext(ctx jobcontext.Current) *OpDependenciesBuilder
func (*OpDependenciesBuilder) WithDatabase ¶
func (b *OpDependenciesBuilder) WithDatabase(db *gorm.DB) *OpDependenciesBuilder
func (*OpDependenciesBuilder) WithGitContext ¶
func (b *OpDependenciesBuilder) WithGitContext(ctx GitExecutionContext) *OpDependenciesBuilder
func (*OpDependenciesBuilder) WithJobTool ¶
func (b *OpDependenciesBuilder) WithJobTool(jt JobTool) *OpDependenciesBuilder
func (*OpDependenciesBuilder) WithOperationPathRuntime ¶ added in v0.0.8
func (b *OpDependenciesBuilder) WithOperationPathRuntime(runtime OperationPathRuntime) *OpDependenciesBuilder
func (*OpDependenciesBuilder) WithOperationPaths ¶ added in v0.0.8
func (b *OpDependenciesBuilder) WithOperationPaths(paths OperationPaths) *OpDependenciesBuilder
func (*OpDependenciesBuilder) WithProtectedEnv ¶ added in v0.0.42
func (b *OpDependenciesBuilder) WithProtectedEnv(env map[string]string) *OpDependenciesBuilder
func (*OpDependenciesBuilder) WithTaskContext ¶
func (b *OpDependenciesBuilder) WithTaskContext(tc jobworkflow.TaskContext) *OpDependenciesBuilder
func (*OpDependenciesBuilder) WithWorkflowControl ¶
func (b *OpDependenciesBuilder) WithWorkflowControl(wc workflowctl.WorkflowControl) *OpDependenciesBuilder
func (*OpDependenciesBuilder) WithWorktreePath ¶
func (b *OpDependenciesBuilder) WithWorktreePath(path string) *OpDependenciesBuilder
type OpExecutor ¶
type OpExecutor interface {
}
type OpInputType ¶
type OpInputType = any
type OpMetadata ¶
type OpMetadata struct {
Type string // Unique identifier for the activity type
Description string // Detailed description
Version string // Semantic version
DefaultTimeout time.Duration // Default execution timeout
AcceptsArtifacts bool // Whether the op accepts inbox artifact bindings
}
OpMetadata describes the activity for registration and documentation. Task-level DisallowAsTask is handled on TaskStep.
type OpOutputType ¶
type OpOutputType = any
type OperationPathProvider ¶ added in v0.0.8
type OperationPathProvider interface {
OperationPaths() OperationPaths
}
type OperationPathRuntime ¶ added in v0.0.8
type OperationPathRuntime struct {
Views OperationPathViews
Mounts []RequiredMount
Ports []RequiredPort
SandboxType string
}
type OperationPathRuntimeProvider ¶ added in v0.0.8
type OperationPathRuntimeProvider interface {
OperationPathRuntime() OperationPathRuntime
}
type OperationPathTransformRequest ¶ added in v0.0.8
type OperationPathTransformRequest struct {
Input map[string]interface{}
Host OperationPaths
}
type OperationPathTransformResult ¶ added in v0.0.8
type OperationPathTransformResult struct {
Runtime OperationPathRuntime
Replacements map[string]string
}
type OperationPathTransformer ¶ added in v0.0.8
type OperationPathTransformer interface {
TransformOperationPaths(context.Context, OperationPathTransformRequest) (OperationPathTransformResult, error)
}
type OperationPathViews ¶ added in v0.0.8
type OperationPathViews struct {
Host OperationPaths
Op OperationPaths
}
type OperationPaths ¶ added in v0.0.8
type RawMessageOrStruct ¶
type RawMessageOrStruct = any
type RegisterableOp ¶
type RegisterableOp interface {
GetMetadata() OpMetadata
GetName() string
TaskChain() []TaskStep
GetManagementService() ManagementService
// contains filtered or unexported methods
}
RegisterableOp defines the contract for ops that can be consumed by external systems like recipe-worker via YAML definitions. Multi-step aware: execution happens per TaskStep in TaskChain.
func Get ¶
func Get(name string) (RegisterableOp, bool)
Get retrieves an operation by name with existence check
func NewActivityMappedOpV2 ¶
func NewActivityMappedOpV2[In any, Out any](metadata OpMetadata, handler ActivityHandlerV2[In, Out]) RegisterableOp
Compatibility helpers: legacy constructors delegate to the builder with a single step.
func NewActivityMappedOpWithProviderV2 ¶
func NewActivityMappedOpWithProviderV2[In any, Out any](metadata OpMetadata, handler ActivityHandlerV2[In, Out], getInputStruct func() interface{}) RegisterableOp
type RequiredMount ¶ added in v0.0.8
type RequiredPort ¶ added in v0.0.42
type Route ¶
type Route struct {
Method string
Path string
Handler http.HandlerFunc
}
Route represents an HTTP route
type SSEManager ¶
type SSEManager interface {
Broadcast(event SSEEvent)
Subscribe(clientID string) <-chan SSEEvent
Unsubscribe(clientID string)
}
SSEManager interface for Server-Sent Events
type ServiceDependencies2 ¶
type ServiceDependencies2 interface {
// WorkflowControl returns a typed workflow controller if available.
WorkflowControl() workflowctl.WorkflowControl
// SSEManager returns the server-sent-event manager when supported.
SSEManager() SSEManager
// Database returns the shared GORM handle for the current runtime when available.
Database() *gorm.DB
// contains filtered or unexported methods
}
ServiceDependencies2 defines the typed dependencies exposed to management services and ops that require access to shared runtime collaborators.
type ServiceDepsBuilder ¶
type ServiceDepsBuilder struct {
// contains filtered or unexported fields
}
ServiceDepsBuilder constructs ServiceDependencies2 instances via a fluent API.
func NewServiceDepsBuilder ¶
func NewServiceDepsBuilder() *ServiceDepsBuilder
NewServiceDepsBuilder returns a new builder for ServiceDependencies2 implementations.
func (*ServiceDepsBuilder) Build ¶
func (b *ServiceDepsBuilder) Build() ServiceDependencies2
Build materializes the immutable ServiceDependencies2 instance.
func (*ServiceDepsBuilder) WithDatabase ¶
func (b *ServiceDepsBuilder) WithDatabase(db *gorm.DB) *ServiceDepsBuilder
WithDatabase configures the shared database handle. Passing nil leaves the dependency unset.
func (*ServiceDepsBuilder) WithSSEManager ¶
func (b *ServiceDepsBuilder) WithSSEManager(mgr SSEManager) *ServiceDepsBuilder
WithSSEManager configures the SSE manager dependency.
func (*ServiceDepsBuilder) WithWorkflowControl ¶
func (b *ServiceDepsBuilder) WithWorkflowControl(ctl workflowctl.WorkflowControl) *ServiceDepsBuilder
WithWorkflowControl configures the workflow controller dependency.
type Step ¶
type Step interface {
// contains filtered or unexported methods
}
Step is an internal interface used by the builder.
func NewNoTaskStep ¶
func NewStep ¶
NewStep constructs a step with signature func(ctx context.Context, in In) (Out, error).
func NewStepWithDeps ¶
func NewStepWithDeps[In any, Out any](fn ActivityHandlerV2[In, Out]) Step
NewStepWithDeps constructs a step with signature func(deps OpDependencies, ctx context.Context, in In) (Out, error).
func StepDisallow ¶
StepDisallow marks a step as disallowed for direct task exposure.
type TaskBasedJobTool ¶
type TaskBasedJobTool struct {
TaskContext jobworkflow.TaskContext
}
func (*TaskBasedJobTool) AwaitJobs ¶
func (j *TaskBasedJobTool) AwaitJobs(jobIds ...string) error
func (*TaskBasedJobTool) GetJobKey ¶
func (j *TaskBasedJobTool) GetJobKey() jobdb.JobKey
type TaskStep ¶
type TaskStep struct {
Name string
InputType reflect.Type
OutputType reflect.Type
DisallowAsTask bool
NextStepTask string
Invoke func(deps OpDependencies, ctx context.Context, resolvedInput map[string]interface{}) (map[string]interface{}, error)
}
TaskStep describes an executable step within an op.