Documentation
¶
Overview ¶
Package argyll provides an API for creating and managing flow steps and flows
It offers client functionality for interacting with the orchestrator, including step registration, flow execution, and async step management, along with the runtime that argyll-gen generated adapters call
Index ¶
- Constants
- Variables
- func NewFlowID(prefix string) api.FlowID
- type AsyncContext
- type Client
- type CompensateHandler
- type Flow
- type FlowClient
- type HTTPError
- type Step
- func (s Step) Build() (*api.Step, error)
- func (s Step) Const(name api.Name, argType api.AttributeType, defaultValue string) Step
- func (s Step) Meta(name api.Name, metaKey string) Step
- func (s Step) Optional(name api.Name, argType api.AttributeType, defaultValue string) Step
- func (s Step) Output(name api.Name, argType api.AttributeType) Step
- func (s Step) Register(ctx context.Context) error
- func (s Step) Required(name api.Name, argType api.AttributeType) Step
- func (s Step) Start(handler StepHandler) error
- func (s Step) Update() Step
- func (s Step) WithAsyncExecution() Step
- func (s Step) WithCompensate(endpoint string) Step
- func (s Step) WithCompensateHandler(handler CompensateHandler) Step
- func (s Step) WithCompensateMethod(method string) Step
- func (s Step) WithCompensateTimeout(timeout int64) Step
- func (s Step) WithEndpoint(endpoint string) Step
- func (s Step) WithFlowGoals(goals ...api.StepID) Step
- func (s Step) WithForEach(name api.Name) Step
- func (s Step) WithHealthCheck(endpoint string) Step
- func (s Step) WithID(id string) Step
- func (s Step) WithLabel(key, value string) Step
- func (s Step) WithLabels(labels api.Labels) Step
- func (s Step) WithLuaPredicate(script string) Step
- func (s Step) WithMemoizable() Step
- func (s Step) WithMethod(method string) Step
- func (s Step) WithName(name api.Name) Step
- func (s Step) WithPredicate(language, script string) Step
- func (s Step) WithRequiredMatch(name api.Name, language, script string) Step
- func (s Step) WithScript(script string) Step
- func (s Step) WithScriptExecution() Step
- func (s Step) WithScriptLanguage(lang, script string) Step
- func (s Step) WithSyncExecution() Step
- func (s Step) WithTimeout(timeout int64) Step
- func (s Step) WithType(stepType api.StepType) Step
- type StepContext
- type StepHandler
Constants ¶
const ( MaxRegistrationAttempts = 5 BackoffMultiplier = 2 * time.Second DefaultEngineURL = "http://localhost:8080" )
const (
DefaultStepPort = 8081
)
Variables ¶
var ( ErrMetadataNotFound = errors.New("metadata not found in step context") ErrWebhookURLNotFound = errors.New("webhook_url not found in metadata") ErrWebhookError = errors.New("webhook returned error status") )
var ( ErrRegisterStep = errors.New("failed to register step") ErrUpdateStep = errors.New("failed to update step") ErrListSteps = errors.New("failed to list steps") ErrStartFlow = errors.New("failed to start flow") ErrGetFlow = errors.New("failed to get flow") ErrGetFlowStatus = errors.New("failed to get flow status") )
var ( ErrStepRegistration = errors.New("failed to register step after retries") ErrHandlerPanic = errors.New("step handler panicked") )
Functions ¶
Types ¶
type AsyncContext ¶
type AsyncContext struct {
*StepContext
// contains filtered or unexported fields
}
AsyncContext provides functionality to manage asynchronous step execution and embeds StepContext with the webhook URL for result delivery
func NewAsyncContext ¶
func NewAsyncContext(ctx *StepContext) (*AsyncContext, error)
NewAsyncContext creates a new async context from a StepContext and extracts webhook_url from the StepContext metadata
func (*AsyncContext) Complete ¶
func (c *AsyncContext) Complete(outputs api.Args) error
Complete sends output arguments to the orchestrator via webhook
func (*AsyncContext) Fail ¶
func (c *AsyncContext) Fail(err error) error
Fail marks the async step as failed with the given error
func (*AsyncContext) FlowID ¶
func (c *AsyncContext) FlowID() string
FlowID returns the flow ID for this async context
func (*AsyncContext) StepID ¶
func (c *AsyncContext) StepID() string
StepID returns the step ID for this async context
func (*AsyncContext) Success ¶
func (c *AsyncContext) Success(outputs api.Args) error
Success marks an async step as successfully completed with the given outputs
func (*AsyncContext) WebhookURL ¶
func (c *AsyncContext) WebhookURL() string
WebhookURL returns the webhook URL for delivering step results
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides functionality for interacting with the orchestrator API, including step registration, flow management, and state queries
func NewClient ¶
NewClient creates a new orchestrator client with the specified base URL and timeout
func (*Client) Flow ¶
func (c *Client) Flow(id api.FlowID) *FlowClient
Flow returns a client for accessing a specific flow
type CompensateHandler ¶
CompensateHandler undoes a completed work item given its inputs and outputs
type Flow ¶
type Flow struct {
// contains filtered or unexported fields
}
Flow is a builder for creating and starting flow executions
func (Flow) WithInitialState ¶
WithInitialState sets the initial state for the flow
type FlowClient ¶
type FlowClient struct {
*Client
// contains filtered or unexported fields
}
FlowClient provides access to a specific flow
func (*FlowClient) FlowID ¶
func (c *FlowClient) FlowID() api.FlowID
FlowID returns the flow ID for this client
func (*FlowClient) GetStatus ¶
func (c *FlowClient) GetStatus( ctx context.Context, ) (*api.FlowStatusResponse, error)
GetStatus retrieves the current status of the flow
type HTTPError ¶
HTTPError allows step handlers to return specific HTTP status codes
func NewHTTPError ¶
NewHTTPError creates a new HTTPError with the given status code and message
type Step ¶
type Step struct {
// contains filtered or unexported fields
}
Step is a builder for creating and configuring flow steps. It provides an API for defining step attributes, predicates, and execution settings
func (Step) Meta ¶
Meta declares a metadata input attribute, injecting the named metadata key as a step input at execution time
func (Step) Start ¶
func (s Step) Start(handler StepHandler) error
Start builds and registers the step, creates an HTTP server, and starts handling requests
func (Step) Update ¶
Update marks this step as modified, so the next Start() will update the existing step registration rather than creating a new one
func (Step) WithAsyncExecution ¶
WithAsyncExecution configures the step to execute asynchronously
func (Step) WithCompensate ¶
WithCompensate sets the compensate endpoint for the step
func (Step) WithCompensateHandler ¶
func (s Step) WithCompensateHandler(handler CompensateHandler) Step
WithCompensateHandler registers a handler for compensation requests
func (Step) WithCompensateMethod ¶
WithCompensateMethod sets the HTTP method used to compensate the step
func (Step) WithCompensateTimeout ¶
WithCompensateTimeout sets the compensate timeout in milliseconds, overriding the step's execution timeout for compensation requests
func (Step) WithEndpoint ¶
WithEndpoint sets the HTTP endpoint where the step handler is listening
func (Step) WithFlowGoals ¶
WithFlowGoals configures a flow step with child flow goal IDs
func (Step) WithForEach ¶
WithForEach marks an attribute as supporting multi work items (arrays)
func (Step) WithHealthCheck ¶
WithHealthCheck sets the HTTP health check endpoint for the step
func (Step) WithLabels ¶
WithLabels merges the provided labels into the step's labels
func (Step) WithLuaPredicate ¶
WithLuaPredicate sets a Lua language predicate script
func (Step) WithMemoizable ¶
WithMemoizable marks the step as eligible for result memoization
func (Step) WithMethod ¶
WithMethod sets the HTTP method used to invoke the step endpoint
func (Step) WithPredicate ¶
WithPredicate sets a predicate script that determines if the step should execute
func (Step) WithRequiredMatch ¶
WithRequiredMatch sets a match predicate for a required attribute. The predicate receives each candidate attribute value as "value" before collect semantics are applied
func (Step) WithScript ¶
WithScript sets a Lua script to execute for this step
func (Step) WithScriptExecution ¶
WithScriptExecution configures the step to execute via a script
func (Step) WithScriptLanguage ¶
WithScriptLanguage sets a script with a specific language to execute for this step
func (Step) WithSyncExecution ¶
WithSyncExecution configures the step to execute synchronously
func (Step) WithTimeout ¶
WithTimeout sets the execution timeout for the step in milliseconds
type StepContext ¶
type StepContext struct {
// Context is the standard Go context for cancellation and deadlines
context.Context
// Client provides access to the current flow's state and operations
Client *FlowClient
// StepID is the ID of the current step being executed
StepID api.StepID
// Metadata contains additional context passed to step handlers
Metadata api.Metadata
}
StepContext provides context and client capabilities to step handlers
type StepHandler ¶
StepHandler is the function signature for step implementations and receives a StepContext which includes both context and flow client
Directories
¶
| Path | Synopsis |
|---|---|
|
Package codec provides composable JSON codecs over encoding/json/jsontext
|
Package codec provides composable JSON codecs over encoding/json/jsontext |
|
Package example contains the step functions used to exercise argyll-gen
|
Package example contains the step functions used to exercise argyll-gen |
|
cmd/argyll-gen
command
Command argyll-gen generates Argyll step adapters for Go functions marked with //argyll:step or //argyll:wrap directives
|
Command argyll-gen generates Argyll step adapters for Go functions marked with //argyll:step or //argyll:wrap directives |