Skip to content
← All SDKs
GO

Go SDK

go get github.com/orch8-io/sdk-go

Features

  • Zero external dependencies (net/http + encoding/json only)
  • Methods across sequences, instances, pools, credentials, circuit breakers, approvals, and more
  • context.Context on all methods, idiomatic error returns
  • Goroutine-based polling worker with circuit breaker awareness — skips open breakers
  • Exponential backoff on poll failures (doubles up to 30s, resets on success)
  • OnTaskComplete / OnTaskFail observability callbacks
  • Channel semaphore for concurrency, inflight tracking, per-task heartbeats
  • Custom headers support via ClientConfig.Headers for auth and routing

Client methods

Full management surface covering all engine API domains.

  • ListSequences / CreateSequence / GetSequence / GetSequenceByName / DeleteSequence / DeprecateSequence / ListSequenceVersions / MigrateInstance
  • CreateInstance / BatchCreateInstances / GetInstance / ListInstances / UpdateInstanceState / UpdateInstanceContext / SendSignal / RetryInstance / InjectBlocks
  • GetOutputs / GetExecutionTree / ListAuditLog
  • ListCheckpoints / SaveCheckpoint / GetLatestCheckpoint / PruneCheckpoints
  • BulkUpdateState / BulkReschedule / ListDLQ
  • ListApprovals
  • ListWorkerTasks / GetWorkerTaskStats / PollTasks / PollTasksFromQueue / CompleteTask / FailTask / HeartbeatTask
  • CreateCron / ListCron / GetCron / UpdateCron / DeleteCron
  • CreateTrigger / ListTriggers / GetTrigger / DeleteTrigger / FireTrigger
  • CreatePlugin / ListPlugins / GetPlugin / UpdatePlugin / DeletePlugin
  • CreateSession / GetSession / GetSessionByKey / UpdateSessionData / UpdateSessionState / ListSessionInstances
  • ListPools / CreatePool / GetPool / DeletePool / ListPoolResources / CreatePoolResource / UpdatePoolResource / DeletePoolResource
  • ListCredentials / CreateCredential / GetCredential / DeleteCredential / UpdateCredential
  • ListCircuitBreakers / GetCircuitBreaker / ResetCircuitBreaker / ListTenantCircuitBreakers / GetTenantCircuitBreaker / ResetTenantCircuitBreaker
  • ListClusterNodes / DrainNode / Health

Management Client

Typed helpers for common management domains. Use the generated REST API for routes not yet wrapped by the installed SDK version.

Go
package main

import (
    "context"
    "fmt"

    orch8 "github.com/orch8-io/sdk-go"
)

func main() {
    client := orch8.NewClient(orch8.ClientConfig{
        BaseURL:  "http://localhost:8080",
        TenantID: "my-tenant",
        Headers:  map[string]string{"x-api-key": "my-key"},
    })

    ctx := context.Background()

    // Sequences
    seq, _ := client.CreateSequence(ctx, map[string]any{
        "tenant_id": "my-tenant",
        "namespace": "default",
        "name":      "onboarding-drip",
        "version":   1,
        "blocks": []map[string]any{
            {"type": "step", "id": "send_welcome", "handler": "send_welcome_email"},
            {"type": "step", "id": "wait_48h", "handler": "noop", "delay": {"duration": 172800000}},
        },
    })

    // Instances
    instance, _ := client.CreateInstance(ctx, map[string]any{
        "sequence_id": seq.ID,
        "tenant_id":   "my-tenant",
        "context":     map[string]any{"data": map[string]any{"userId": "usr_123"}},
    })

    // Checkpoints
    client.SaveCheckpoint(ctx, instance.ID, map[string]any{"progress": 42})
    latest, _ := client.GetLatestCheckpoint(ctx, instance.ID)
    fmt.Printf("Checkpoint: %v\n", latest)

    // Cron
    client.CreateCron(ctx, map[string]any{
        "tenant_id":   "my-tenant",
        "sequence_id": seq.ID,
        "expression":  "0 9 * * 1",
        "timezone":    "America/Sao_Paulo",
    })

    // Circuit breakers
    breakers, _ := client.ListCircuitBreakers(ctx)
    fmt.Printf("Breakers: %d\n", len(breakers))

    // Cluster
    nodes, _ := client.ListClusterNodes(ctx)
    fmt.Printf("Nodes: %d\n", len(nodes))
}

Polling Worker

Register handler functions and let the worker poll, execute, heartbeat, and report results automatically.

Go
package main

import (
    "context"
    "fmt"
    "time"

    orch8 "github.com/orch8-io/sdk-go"
)

func main() {
    client := orch8.NewClient(orch8.ClientConfig{
        BaseURL:  "http://localhost:8080",
        TenantID: "my-tenant",
    })

    worker := orch8.NewWorker(orch8.WorkerConfig{
        Client:            client,
        WorkerID:          "worker-1",
        PollInterval:      time.Second,
        HeartbeatInterval: 15 * time.Second,
        MaxConcurrent:     10,
        Handlers: map[string]orch8.HandlerFunc{
            "send_welcome_email": func(ctx context.Context, task orch8.WorkerTask) (any, error) {
                email := task.Context["data"].(map[string]any)["email"].(string)
                fmt.Printf("Sending welcome to %s\n", email)
                return map[string]any{"sent": true}, nil
            },
            "check_engagement": func(ctx context.Context, task orch8.WorkerTask) (any, error) {
                return map[string]any{"route": "engaged"}, nil
            },
        },
    })

    worker.Start(context.Background())
}

Full API reference

SDK coverage follows each package release and can lag new engine routes. For exact request and response schemas, use the generated OpenAPI document from the engine version you run.

View the API guide →