Basic
The simplest Turbine workflow: register a function and run it.
What to notice:
turbine.NewStandalonecreates the runtime,rt.Launch()starts it, the deferredrt.Shutdown()tears it down on exit- Workflow signature:
func(ctx turbine.Context, input P) (R, error) handle.GetResult()blocks until the workflow completes
go
package main
import (
"log"
"github.com/YakirOren/turbine"
)
func Greet(ctx turbine.Context, name string) (string, error) {
return "hello, " + name, nil
}
func main() {
rt := turbine.NewStandalone(turbine.Config{})
defer rt.Shutdown()
turbine.Register(rt, Greet)
if err := rt.Launch(); err != nil {
log.Fatal(err)
}
handle, err := turbine.Run(rt, Greet, "world")
if err != nil {
log.Fatal(err)
}
result, err := handle.GetResult()
if err != nil {
log.Fatal(err)
}
log.Println(result)
}