basic_usage

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2025 License: AGPL-3.0 Imports: 3 Imported by: 0

README

Basic Usage Example

This example demonstrates the basic usage of the steps package by creating and running a DAG (Directed Acyclic Graph) with multiple steps in sequence.

Overview

The example shows:

  1. How to create a step using the Step function
  2. How to create a DAG (Directed Acyclic Graph) using NewDag()
  3. How to add multiple steps to the DAG
  4. How to run the DAG with context and data

Key Concepts

  • Step Creation: Using the Step function to create steps that perform operations
  • DAG Structure: Using NewDag() to create a directed acyclic graph of steps
  • Step Addition: Using RunnableAdd() to add steps to the DAG
  • Execution: Running the DAG with context and data map

Example Code

Here's a quick overview of the example code:

// Create a new DAG
func NewMultipleIncrementDag() steps.DagInterface {
    dag := steps.NewDag()
    dag.SetName("Multiple Increment DAG")
    
    // Add 4 increment steps
    for i := 0; i < 4; i++ {
        dag.RunnableAdd(NewIncrementStep())
    }
    
    return dag
}

Running the Example

To run this example:

# Run the main program
# This will execute a DAG with 4 increment steps
# The initial value is 0 and it will be incremented 4 times
# The final value should be 4

go run main.go

# Run the tests
# The test verifies that the DAG correctly increments the value 4 times
go test -v

Expected Output

The program will output:

Value: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIncrementStep

func NewIncrementStep() wf.StepInterface

NewIncrementStep creates a new step that increments a value

func NewMultipleIncrementDag

func NewMultipleIncrementDag() wf.DagInterface

NewMultipleIncrementDag creates a DAG with multiple increment steps

func NewSetValueStep

func NewSetValueStep() wf.StepInterface

NewSetValueStep creates a new step that sets a value

Types

This section is empty.

Jump to

Keyboard shortcuts

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