Documentation
¶
Overview ¶
Package engine provides a public API for executing Lacquer workflows programmatically. This package allows third-party applications to integrate Lacquer workflow execution capabilities directly into their codebase.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunWorkflow ¶
func RunWorkflow(ctx context.Context, workflowFile string, inputs map[string]interface{}, outputs any, options ...Option) error
outputs := &struct {
ProcessedData string `json:"processed_data"`
}{}
err := RunWorkflow(context.Background(), "data-processing.laq.yml", inputs, outputs)
if err != nil {
return fmt.Errorf("workflow failed: %w", err)
}
result := outputs["processed_data"]
// With progress monitoring listener := &MyProgressListener{} err = RunWorkflow(
context.Background(), "complex-workflow.laq.yml", inputs, outputs, WithProgressListener(listener)
)
Types ¶
type Option ¶
Option represents a functional option for configuring workflow execution. Options allow customization of the workflow runner behavior, such as adding progress listeners or modifying execution parameters.
Options follow the functional options pattern, allowing for flexible and extensible configuration of the workflow execution engine.
func WithProgressListener ¶
WithProgressListener creates an Option that configures a progress listener for monitoring workflow execution events in real-time.
The provided listener will receive execution events throughout the workflow lifecycle, including workflow start/completion, step progress, errors, and retry attempts. This enables real-time monitoring and logging of workflow execution progress.
Parameters:
- listener: An implementation of events.Listener that will receive execution events
Returns:
- Option: A functional option that can be passed to RunWorkflow
Example:
type MyListener struct{}
func (l *MyListener) StartListening(progressChan <-chan events.ExecutionEvent) {
for event := range progressChan {
fmt.Printf("Event: %s at %s\n", event.Type, event.Timestamp)
}
}
func (l *MyListener) StopListening() {
fmt.Println("Progress tracking stopped")
}
listener := &MyListener{}
outputs, err := RunWorkflow("workflow.laq.yml", inputs, WithProgressListener(listener))