docs: consolidate runnable examples and publish v0.1.1 guides

This commit is contained in:
2026-09-24 21:27:25 +08:00
parent e29dec717f
commit 81e56bd633
124 changed files with 1430 additions and 281 deletions

37
examples/health/main.go Normal file
View File

@@ -0,0 +1,37 @@
// Run against a started bootstrap server: ORBIT_URL=http://127.0.0.1:8080 go run ./health
package main
import (
"context"
"fmt"
orbit "git.yuntuo.hk/k2safe/orbit/sdk/go"
"log"
"os"
"time"
)
func main() {
address := os.Getenv("ORBIT_URL")
if address == "" {
address = "http://127.0.0.1:8080"
}
client, err := orbit.NewClient(address, orbit.Options{})
if err != nil {
log.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
live, err := client.Liveness(ctx)
if err != nil {
log.Fatal(err)
}
ready, err := client.Readiness(ctx)
if err != nil {
log.Fatal(err)
}
version, err := client.Version(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("liveness=%s readiness=%s scope=%s version=%s revision=%s\n", live.Status, ready.Status, ready.Scope, version.Version, version.Revision)
}