Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to run workflow without middleware independency #76

Open
OhBonsai opened this issue Jul 3, 2023 · 4 comments
Open

[Question] How to run workflow without middleware independency #76

OhBonsai opened this issue Jul 3, 2023 · 4 comments

Comments

@OhBonsai
Copy link

OhBonsai commented Jul 3, 2023

It's good for triggering workflow by api. But sometimes i wanna run my workflow in command mode. I wanna keep my workflow definition.

package amin

import (
	"fmt"
	flow "github.com/s8sg/goflow/flow/v1"
)

// Workload function
func node1(data []byte, option map[string][]string) ([]byte, error) {
	result := fmt.Sprintf("(Executing node 1 with data (%s))", string(data))
	fmt.Println(result)
	return []byte(result), nil
}

// DefineWorkflow Define provide definition of the workflow
func DefineWorkflow(workflow *flow.Workflow, context *flow.Context) error {
	dag := workflow.Dag()
	dag.Node("node1", node1)
	return nil
}

then run this workflow in main

workflow.Run("my-workflow")

@s8sg
Copy link
Owner

s8sg commented Jul 3, 2023 via email

@OhBonsai
Copy link
Author

OhBonsai commented Jul 4, 2023

We already support running in worker mode. It doesn’t run the http server. If thats what you are asking for

In worker mode, we need to connect to Redis to store and process task states and results. However, I hope to keep only the definition of workflows and not need to connect to Redis. Because my workerload is running in different network environments and the worker nodes can only connect to the server via HTTP to get tasks.

@s8sg
Copy link
Owner

s8sg commented Jul 6, 2023

Can you explain more like why you require only the definition?

@OhBonsai
Copy link
Author

image

implement a SQLite state store, maybe a good idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants