Getting Started
Install
bash
go get github.com/YakirOren/turbineQuick Start
go
package main
import (
"log"
"github.com/YakirOren/turbine"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
)
func main() {
app := pocketbase.New()
rt := turbine.Setup(app, turbine.Config{})
greet := func(ctx turbine.Context, name string) (string, error) {
return "hello " + name, nil
}
turbine.Register(rt, greet)
app.OnServe().BindFunc(func(e *core.ServeEvent) error {
e.Router.POST("/greet/{name}", func(re *core.RequestEvent) error {
name := re.Request.PathValue("name")
handle, err := turbine.Run(rt, greet, name)
if err != nil {
return re.JSON(500, map[string]string{"error": err.Error()})
}
result, err := handle.GetResult()
if err != nil {
return re.JSON(500, map[string]string{"error": err.Error()})
}
return re.JSON(200, map[string]string{"result": result})
})
return e.Next()
})
if err := app.Start(); err != nil {
log.Fatal(err)
}
}What Happens on First Launch
What happens on first launch
When PocketBase starts, Turbine automatically:
- Creates the SQLite collections it needs (
pt_workflow_status,pt_operation_outputs, etc.) - Recovers any pending workflows from a previous run
- Starts the queue runner and cron scheduler
What's Next?
- Workflows — how workflows work, registration, and run options
- Steps — durable execution units
- Queues — concurrency control and rate limiting
- Scheduling — cron-based workflows
- Communication — inter-workflow messaging
- Approvals — human-in-the-loop gates
- Products — file outputs from workflows
- KV Store — global key-value storage
- Error Handling — error types and patterns
- Lifecycle — setup, shutdown, and introspection