Quickstart · attos-go
Attos compiles arbitrary key sets into a Minimal Perfect Hash Function (MPHF) and streams the resulting artifact to your service. Lookups are local pointer arithmetic — p99 43ns, zero allocations.
1. Install the SDK
Requires Go 1.22 or newer. The module has no cgo dependencies.
go get github.com/Attos-Labs/attos-go@latest2. Initialize NewSynchronizer
NewSynchronizer opens a long-lived stream to the Attos control plane, downloads the latest artifact for your dataset, and reloads it in place whenever a new version is compiled.
package main
import (
"context"
"log"
"github.com/Attos-Labs/attos-go"
)
func main() {
sync, err := attos.NewSynchronizer(context.Background(), attos.Config{
Token: "attos_pat_9f3a21…", 500">// personal or service token
Dataset: "edge-router",
Region: "us-west-2",
CacheDir: "/var/lib/attos", 500">// mmap-backed local artifact
})
if err != nil {
log.Fatalf("attos: %v", err)
}
defer sync.Close()
500">// sync.Ready() blocks until the first artifact is loaded.
<-sync.Ready()
log.Printf("attos ready · version=%s keys=%d", sync.Version(), sync.KeyCount())
}3. Perform a lookup
Lookup returns a dense integer index in constant time. Combine it with your own value slice to map keys → backends, feature flags, or rate limits.
idx, ok := sync.Lookup("api.customer-42.io")
if !ok {
return errUnknownHost
}
backend := backends[idx] 500">// O(1), no allocations4. Hot reload (no restart)
The Synchronizer swaps the underlying mmap atomically. In-flight readers keep the previous artifact until they return; new readers see the fresh one.
sync.OnReload(func(v attos.Version) {
log.Printf("attos reloaded → %s (%d keys, %s)", v.Tag, v.KeyCount, v.Size)
})Next: read the full Go SDK reference or explore the REST API for control-plane automation.