zchpc-go

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2026 License: MIT

README

zchpc-go

The Go client for ZCHPC: rent GPU slices, and provision managed databases, caches and S3-compatible media buckets.

go get github.com/movella-systems/zchpc-go

Rent a GPU

Use destroys the rental on the way out, including when your callback returns an error. A GPU bills by the second, and the usual way a box gets left running is a failure between renting it and destroying it.

z := zchpc.New("gpv_YOUR_API_KEY")   // or set ZCHPC_API_KEY

err := z.GPUs.Use(ctx, zchpc.RentSpec{GPUMemGB: 8, Hours: 1},
    func(gpu *zchpc.Instance) error {
        info, err := gpu.GPUInfo()
        fmt.Println(info)   // Tesla V100S-PCIE-32GB, 32768 MiB, 0 MiB
        return err
    })

Databases, caches and buckets

Go has no optional dependencies, so this client stops at the connection details rather than pulling pgx, go-redis and aws-sdk into every build that imports it. What it hands back is standard, so your usual driver takes it unchanged.

db, _ := z.Databases.Create(ctx, zchpc.DatabaseSpec{Name: "notes"})
db, _ = db.Wait(ctx)

conn, _ := pgx.Connect(ctx, db.URI)   // password already in the URI

For buckets, set path-style addressing. Amazon puts the bucket in the hostname and every SDK defaults to that, but this endpoint serves buckets as a path.

b, _ := z.Buckets.Create(ctx, "media", zchpc.BucketSpec{})

client := s3.New(s3.Options{
    BaseEndpoint: aws.String(b.EndpointURL()),
    Credentials:  credentials.NewStaticCredentialsProvider(b.AccessKey, b.SecretKey, ""),
    UsePathStyle: true,
})

Errors

Typed by what you can do about them, so errors.Is is enough: ErrAuth, ErrInsufficientCredit, ErrLimitReached, ErrNotFound, ErrProvisioning, ErrWaitTimeout.

License

MIT

Directories

Path Synopsis
Exercise the Go SDK against a running backend, the same way the Node and Python clients were exercised.
Exercise the Go SDK against a running backend, the same way the Node and Python clients were exercised.
Package zchpc is one client for ZCHPC GPUs, managed databases, caches and media buckets.
Package zchpc is one client for ZCHPC GPUs, managed databases, caches and media buckets.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL