Replace Python handler-base library with Go module providing: - config: environment-based configuration - health: HTTP health/readiness server for k8s probes - natsutil: NATS/JetStream client with msgpack serialization - telemetry: OpenTelemetry tracing and metrics setup - clients: HTTP clients for LLM, embeddings, reranker, STT, TTS - handler: base Handler runner wiring NATS + health + telemetry Implements ADR-0061 Phase 1.
45 lines
1.1 KiB
Markdown
45 lines
1.1 KiB
Markdown
# handler-base
|
|
|
|
Go module providing shared infrastructure for NATS-based handler services.
|
|
|
|
## Packages
|
|
|
|
| Package | Purpose |
|
|
|---------|---------|
|
|
| `config` | Environment-based configuration via struct fields |
|
|
| `health` | HTTP health/readiness server for Kubernetes probes |
|
|
| `natsutil` | NATS/JetStream client with msgpack serialization |
|
|
| `telemetry` | OpenTelemetry tracing and metrics setup |
|
|
| `clients` | HTTP clients for LLM, embeddings, reranker, STT, TTS |
|
|
| `handler` | Base Handler runner wiring NATS + health + telemetry |
|
|
|
|
## Usage
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"git.daviestechlabs.io/daviestechlabs/handler-base/config"
|
|
"git.daviestechlabs.io/daviestechlabs/handler-base/handler"
|
|
"github.com/nats-io/nats.go"
|
|
)
|
|
|
|
func main() {
|
|
cfg := config.Load()
|
|
cfg.ServiceName = "my-service"
|
|
|
|
h := handler.New("my.subject", cfg)
|
|
h.OnMessage(func(ctx context.Context, msg *nats.Msg, data map[string]any) (map[string]any, error) {
|
|
return map[string]any{"ok": true}, nil
|
|
})
|
|
h.Run()
|
|
}
|
|
```
|
|
|
|
## Testing
|
|
|
|
```bash
|
|
go test ./...
|
|
```
|