amps-client-go

module
v0.8.20 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT

README

amps-client-go

A feature-complete, high-performance Go client for AMPS — built from scratch to match and outperform the official C/C++ client on critical hot paths.

CI Release Latest Release Go Reference Go Version License Docs Coverage Gate Open Issues Open PRs GitHub stars

Version: 0.8.20


Why This Client?

AMPS is one of the fastest message brokers on the planet. Building a client worthy of that speed — in Go, without CGO — was the goal. This project delivers:

  • 🏎️ Faster than C on the hot path — Go client outperforms the official C library on header parsing and SOW batch processing at p95/p99
  • 🔬 261 parity-mapped symbols — full Client and HAClient API surface, tested against C++ 5.3.5.1 behavior
  • 🛡️ Production-grade quality gates — 90%+ coverage, zero open parity gaps, enforced regression budgets on every PR
  • Zero-allocation critical paths — header parse, uint decode, timeout poll, and string conversion all run at 0 allocs/op
  • 🔄 HA failover built in — reconnect strategies, bookmark replay, publish stores, and server chooser with no manual plumbing

If you're building on AMPS and you need a Go-native client that doesn't compromise on performance, this is it.


Performance: Go vs Official C Client

All benchmarks run on the same machine, same workload, same measurement methodology (nearest-rank percentiles, 20 samples). Lower is better.

Hot-Path Parity Results (Go vs Official C)

These are the strict parity workloads we currently gate for C-vs-Go comparisons. Lower is better.

Benchmark Go p95 (ns/op) C p95 (ns/op) Delta Winner
Header Parse (strict parity) 18.41 22.38 -17.7% Go
SOW Batch Parse (strict parity) 93.34 123.14 -24.2% Go
Header Serialize (strict parity) 68.88 69.60 -1.0% Go
Publish Integration (processed ack) 101380 245025.75 -58.6% Go
Subscribe Integration (processed ack) 105067 225831 -53.5% Go

This is 5/5 wins on the in-scope hot-path parity suite (p95).

Connect-and-logon timings are tracked separately and treated as out of scope for this steady-state hot-path gate.

Full-Suite Tail Latency (Go Internal Benchmarks)

Every hot path in the client is micro-benchmarked and tracked across commits. Here are the current numbers at p95 (20 samples each):

Hot Path p95 (ns/op) Allocs/Op
Header parse 21.44 0
SOW batch parse 78.27 0
Route dispatch (single) 139.0
Route dispatch (many subscriptions) 137.7
Frame decode → dispatch 177.3
Publish send (full frame) 48.7 0
Uint parse (bytes) 8.87 0
Stream dequeue 75.39
Stream timeout poll 12.79 0
Header reset 0.13 0
Ack serialization 21.79
How We Measure

Feature Completeness

This isn't a minimal SDK. It's a full-surface client with behavior parity across the entire C++ Client and HAClient public API.

Dimension Status
Parity symbols mapped 261 (zero gaps)
Behavior gaps open 0
Coverage gate (aggregate) ≥ 90%
Coverage gate (pure-functional) 100%
C compatibility layer (amps/capi) ✅ Full
C++ utility compat (amps/cppcompat) ✅ Full
Supported Workflows
Workflow Primary APIs
Pub/sub and delta publish Publish, DeltaPublish, Subscribe*, DeltaSubscribe*
SOW queries Sow*, SowAndSubscribe*, SowAndDeltaSubscribe*, SowDelete*
Queue acknowledgement Ack, SetAutoAck, SetAckBatchSize, SetAckTimeout, FlushAcks
Queue backlog requests SetMaxBacklog, SubscribeWithMaxBacklog, SubscribeAsyncWithMaxBacklog
Bookmark replay BookmarkSubscribe*, BookmarkStore implementations
Bookmark replay controls SetBookmarkNotFound*, SetFullyDurable, SOWHistoricalQueryAndSubscribe
Publish persistence PublishStore implementations, PublishFlush
HA failover & reconnect HAClient.ConnectAndLogon, server chooser, delay strategies
TCP/TLS transport compression SetCompression, compression=zlib on tcp/tcps URIs
Kerberos auth (pure Go) amps/auth/kerberos.NewAuthenticator
Transport hooks Transport filter, receive-start callback, global handlers

Install

go get github.com/Thejuampi/amps-client-go/amps

Spark-Compatible CLI

gofer is the repository's spark-compatible command-line client.

go run ./cmd/gofer help
go run ./cmd/gofer ping -server localhost:9007 -type json
go run ./cmd/gofer publish -server localhost:9007 -type json -topic orders -data '{"id":1}'

Fake AMPS Harness

tools/fakeamps now supports AMPS-style XML server configuration in addition to flags.

go run ./tools/fakeamps --sample-config
go run ./tools/fakeamps --verify-config config.xml
go run ./tools/fakeamps --dump-config config.xml
go run ./tools/fakeamps --config config.xml

It also serves a browser dashboard and monitoring API from the admin listener:

go run ./tools/fakeamps --config config.xml
# then open http://127.0.0.1:8085/

See tools/fakeamps/README.md for the supported XML sections, dashboard/admin routes, the Extensions/FakeAMPS runtime block, and the deterministic validation rules for unsupported custom modules and UDFs.

Quick Start

package main

import (
 "fmt"

 "github.com/Thejuampi/amps-client-go/amps"
)

func main() {
 client := amps.NewClient("example-client")
 if err := client.Connect("tcp://localhost:9000/amps/json"); err != nil {
  panic(err)
 }
 defer client.Close()

 if err := client.Logon(); err != nil {
  panic(err)
 }

 _, err := client.SubscribeAsync(func(message *amps.Message) error {
  fmt.Println(string(message.Data()))
  return nil
 }, "orders")
 if err != nil {
  panic(err)
 }

 if err := client.Publish("orders", `{"id":1}`); err != nil {
  panic(err)
 }
}

Documentation

📖 Full Documentation Index

Getting Started Production Reference
Getting Started Queue Ack Semantics Client API
Client Entrypoints Bookmarks and Replay HAClient API
Pub/Sub and SOW HA Failover Types and Handlers
Supported Scope Operational Playbook C API Compat
C++ Compat
C++ Parity Matrix

Build and Test

make build
make static-scan
make leak-check
make fuzz-smoke
make test-race
make test
make integration-test
make integration-live-smoke
make stress-check
make parity-check
make coverage-check
make perf-check
make vuln-scan
make preprod-check
make release

make static-scan now combines go vet, staticcheck, ineffassign, errcheck, the repo-specific patterncheck analyzer, and an expanded bug-focused golangci-lint lane.

Equivalent direct commands
go vet ./...
go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 -checks=SA* ./...
go run github.com/gordonklaus/ineffassign@v0.2.0 ./...
go run github.com/kisielk/errcheck@v1.10.0 -ignoretests ./...
go run ./tools/patterncheck ./...
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8 run --config .golangci.yml ./...
go test -count=1 ./amps
go test -count=1 ./tools/fakeamps -run '^(TestStartLeaseWatcher|TestStopLeaseWatcherStopsBackgroundLoop)$$'
go test ./amps -run=^$$ -fuzz=FuzzParseHeader -fuzztime=5s
go test ./amps -run=^$$ -fuzz=FuzzParseBookmarkToken -fuzztime=5s
go test ./amps -run=^$$ -fuzz=FuzzParseSocketOptions -fuzztime=5s
go test ./amps -run=^$$ -fuzz=FuzzCompositeMessageParser -fuzztime=5s
go test -race ./... -skip Integration
go test ./... -skip Integration
go test ./... -run Integration
go test -count=1 ./amps -run '^(TestIntegrationConnectLogonPublishSubscribe|TestIntegrationSOWAndSowAndSubscribeLifecycle|TestIntegrationQueueAutoAckBatching|TestIntegrationBookmarkResumeAcrossReconnect|TestIntegrationHAConnectAndLogonWithFailoverChooser)$$'
go test -race -shuffle=on -count=20 ./... -skip Integration
go run ./tools/paritycheck -manifest tools/parity_manifest.json
go test -count=1 ./amps/... -coverprofile=coverage.out
go run ./tools/coveragegate -profile coverage.out
make compat-check
make perf-compare-toolchains
go run ./tools/withtoolchain -toolchain go1.25.10+auto -- run ./tools/perfgate -baseline tools/perf_baseline.json
go run ./tools/withtoolchain -toolchain go1.25.10+auto -- run golang.org/x/vuln/cmd/govulncheck@v1.1.4 ./...

Static analysis is enforced in CI with make static-scan, which includes vet, staticcheck correctness checks, ineffassign, errcheck on non-test packages, patterncheck, and an expanded golangci-lint lane for bug detectors such as aliasing hazards, unicode traps, resource leaks, loop-variable mistakes, compiler-directive misuse, shadowed variables, unused writes, nil/error contract mistakes, suspicious assignments, and duration arithmetic errors.

Leak detection, fuzz smoke, and repeated shuffled race stress runs are exposed separately through make leak-check, make fuzz-smoke, and make stress-check, and combined in make preprod-check.

make vuln-scan runs govulncheck as an advisory scan. Standard-library findings depend on the Go patch version in use, so the workflow records those results without making them a required merge blocker.

The module minimum stays at Go 1.25 for downstream compatibility, with Go 1.25.10 as the current release/performance toolchain. Go 1.26.3 is a performance candidate only after make perf-compare-toolchains proves a faster AMPS client on the same commit and host. That target writes raw Go 1.25.10 and Go 1.26.3 benchmark outputs plus a benchstat report under .tmp/perf/; neutral, noisy, or slower results are not a reason to recapture tools/perf_baseline.json or publish a performance release.

GitHub Actions now enforce an Ubuntu analysis job, a cross-platform test matrix, and a scheduled nightly pre-production workflow, with optional live AMPS smoke coverage whenever AMPS_TEST_* secrets are configured.

Coverage gating is expected before merge for ./amps/...: aggregate >=90.0%, pure-functional files 100.0%, and I/O/stateful files >=80.0% as enforced by tools/coveragegate/main.go.

PowerShell note: quote the coverprofile flag if needed, for example go test -count=1 ./amps/... '-coverprofile=coverage.out'.

License

MIT. See LICENSE.

Directories

Path Synopsis
Package amps provides a Go implementation of the AMPS client protocol with parity-oriented behavior for the Client and HAClient APIs.
Package amps provides a Go implementation of the AMPS client protocol with parity-oriented behavior for the Client and HAClient APIs.
capi
Package capi provides C-style handle APIs for AMPS client compatibility.
Package capi provides C-style handle APIs for AMPS client compatibility.
cppcompat
Package cppcompat provides Go adapters for C++ AMPS utility and model APIs.
Package cppcompat provides Go adapters for C++ AMPS utility and model APIs.
cmd
gofer command
Package main implements gofer — a cross-platform CLI for interacting with AMPS instances.
Package main implements gofer — a cross-platform CLI for interacting with AMPS instances.
internal
tools
coveragegate command
fakeamps command
Package main implements fakeamps — a deterministic, stateful AMPS-protocol TCP responder for integration and performance testing of custom AMPS client implementations.
Package main implements fakeamps — a deterministic, stateful AMPS-protocol TCP responder for integration and performance testing of custom AMPS client implementations.
fakeampsgate command
paritycheck command
patterncheck command
perfgate command
perfreport command
withtoolchain command

Jump to

Keyboard shortcuts

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