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)
  • 75 methods covering all engine domains — 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 (75)

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

API coverage

The engine exposes 122+ REST endpoints across 20 domains. = full, ~ = partial, W = via worker SDK, = use REST API directly.

DomainEndpointsThis SDK
Sequences7
Instances13
Checkpoints4
Audit log1
Bulk operations2
Dead letter queue1
Worker tasks7
Cron schedules5
Triggers5
Plugins5
Sessions6
Credentials5
Resource pools8
Approvals1
Circuit breakers6incl. per-tenant
Cluster2
Health2~ready only
SSE streaming1
Instance migration1
Block injection1

Management Client

Full API surface — sequences, instances, pools, credentials, cron, triggers, sessions, DLQ, circuit breakers, and more.

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{"Authorization": "Bearer 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", "handler": "send_welcome_email"},
            {"type": "Step", "handler": "wait_48h", "delay": "48h"},
        },
    })

    // 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.

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

All SDKs cover the complete engine API. For the raw REST documentation including request/response schemas and authentication details, see the API reference.

View full API reference (122+ endpoints) →