Skip to content

Commit a72bf38

Browse files
committed
docs: update README and migration guide for final package structure
Reflect the final state: 18 packages, no db/, auth/, testkit/, or telemetry/otelhttpclient. Update all package tables, dependency lists, and migration instructions.
1 parent c32b040 commit a72bf38

File tree

2 files changed

+44
-50
lines changed

2 files changed

+44
-50
lines changed

MIGRATION.md

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,27 @@ Update `go.mod` to require Go 1.24:
1010
go 1.24
1111
```
1212

13-
## Package moves
13+
## Packages removed
1414

15-
Update import paths:
15+
| Removed | Replacement |
16+
|---------|-------------|
17+
| `observability/logger` | Use `*slog.Logger` from `log/slog` directly |
18+
| `observability/otelgrpc` | Use `connectrpc.com/otelconnect` |
19+
| `observability/otelhttpclient` | Use `go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp` |
20+
| `server/mux` | Use `github.com/raystack/salt/server` |
21+
| `db` | Use your preferred DB library (sqlx, pgx, gorm) directly |
22+
| `auth/oidc` | Planned as complete CLI auth solution (#86) |
23+
| `auth/audit` | Planned with standardized schema (#87) |
24+
| `testing/dockertestx` | Use `ory/dockertest/v3` directly |
25+
26+
## Packages moved
1627

1728
| Old | New |
1829
|-----|-----|
19-
| `github.com/raystack/salt/observability/logger` | Removed — use `*slog.Logger` from `log/slog` |
20-
| `github.com/raystack/salt/observability` | `github.com/raystack/salt/telemetry` |
21-
| `github.com/raystack/salt/observability/otelhttpclient` | `github.com/raystack/salt/telemetry/otelhttpclient` |
22-
| `github.com/raystack/salt/observability/otelgrpc` | Removed — use `connectrpc.com/otelconnect` |
23-
| `github.com/raystack/salt/server/mux` | Removed — use `github.com/raystack/salt/server` |
24-
| `github.com/raystack/salt/testing/dockertestx` | `github.com/raystack/salt/testkit` |
25-
| `github.com/raystack/salt/cli/terminator` | `github.com/raystack/salt/cli/terminal` |
26-
| `github.com/raystack/salt/cli/prompter` | `github.com/raystack/salt/cli/prompt` |
27-
| `github.com/raystack/salt/cli/releaser` | `github.com/raystack/salt/cli/version` |
30+
| `observability` | `telemetry` |
31+
| `cli/terminator` | `cli/terminal` |
32+
| `cli/prompter` | `cli/prompt` |
33+
| `cli/releaser` | `cli/version` |
2834

2935
## Logger
3036

@@ -79,14 +85,13 @@ import "github.com/raystack/salt/app"
7985
app.Run(
8086
app.WithConfig(&cfg, config.WithFile("config.yaml")),
8187
app.WithLogger(slog.Default()),
82-
app.WithDB(cfg.DB),
83-
app.WithTelemetry(cfg.Telemetry),
88+
app.WithHTTPMiddleware(middleware.DefaultHTTP(slog.Default())),
8489
app.WithHandler("/api/", handler),
8590
app.WithAddr(cfg.Addr),
8691
)
8792
```
8893

89-
HTTP middleware (recovery, request ID, request logging, CORS) is auto-applied using the app's logger.
94+
HTTP middleware is explicit — use `middleware.DefaultHTTP(logger)` for the standard chain or compose your own. Database connections are managed via `app.WithOnStart` / `app.WithOnStop` hooks.
9095

9196
## CLI bootstrap
9297

@@ -180,10 +185,25 @@ import "github.com/raystack/salt/middleware"
180185
interceptors := middleware.Default(slog.Default())
181186
handler := myv1connect.NewServiceHandler(svc, connect.WithInterceptors(interceptors...))
182187

183-
// HTTP middleware (auto-applied by app.Run, or manually)
188+
// HTTP middleware
184189
httpMW := middleware.DefaultHTTP(slog.Default())
185190
```
186191

192+
## Config
193+
194+
```go
195+
// Import path for validator changed
196+
// Before: "github.com/go-playground/validator"
197+
// After: "github.com/go-playground/validator/v10"
198+
199+
// If you imported go-defaults directly:
200+
// Before: "github.com/mcuadros/go-defaults"
201+
// After: "github.com/creasty/defaults"
202+
// API change: defaults.SetDefaults(cfg) → defaults.Set(cfg)
203+
```
204+
205+
The config package no longer prints warnings to stdout when a config file is missing.
206+
187207
## Dependency changes
188208

189209
| Removed (direct) | Replacement |
@@ -197,6 +217,9 @@ httpMW := middleware.DefaultHTTP(slog.Default())
197217
| `pkg/errors` | `fmt.Errorf` with `%w` (stdlib) |
198218
| `mcuadros/go-defaults` | `creasty/defaults` |
199219
| `go-playground/validator` v9 | `go-playground/validator/v10` |
220+
| `jmoiron/sqlx` | Use directly if needed |
221+
| `golang-migrate` | Use directly if needed |
222+
| `ory/dockertest` | Use directly if needed |
200223

201224
| Added | Purpose |
202225
|-------|---------|
@@ -212,18 +235,3 @@ httpMW := middleware.DefaultHTTP(slog.Default())
212235
| `briandowns/spinner` | v1.18 → v1.23.2 |
213236
| `schollz/progressbar` | v3.8 → v3.19.0 |
214237
| `mattn/go-isatty` | v0.0.19 → v0.0.21 |
215-
216-
## Config
217-
218-
The config package no longer prints warnings to stdout when a config file is missing. Missing files are silently ignored (env vars and defaults still apply). Parse errors are now returned as errors.
219-
220-
```go
221-
// Import path for validator changed
222-
// Before: "github.com/go-playground/validator"
223-
// After: "github.com/go-playground/validator/v10"
224-
225-
// If you imported go-defaults directly in tests:
226-
// Before: "github.com/mcuadros/go-defaults"
227-
// After: "github.com/creasty/defaults"
228-
// API change: defaults.SetDefaults(cfg) → defaults.Set(cfg)
229-
```

README.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
The standard way to build raystack services and CLIs.
88

9-
Salt provides two entry points — `app.Run()` for services and `cli.Execute()` for command-line tools — along with the building blocks they use: configuration, database, telemetry, middleware, terminal output, and more.
9+
Salt provides two entry points — `app.Run()` for services and `cli.Execute()` for command-line tools — along with the building blocks they use: configuration, middleware, terminal output, and more.
1010

1111
## Quick start
1212

@@ -20,6 +20,7 @@ import (
2020

2121
"github.com/raystack/salt/app"
2222
"github.com/raystack/salt/config"
23+
"github.com/raystack/salt/middleware"
2324
)
2425

2526
func main() {
@@ -28,14 +29,14 @@ func main() {
2829
app.Run(
2930
app.WithConfig(&cfg, config.WithFile("config.yaml")),
3031
app.WithLogger(slog.Default()),
31-
app.WithDB(cfg.DB),
32+
app.WithHTTPMiddleware(middleware.DefaultHTTP(slog.Default())),
3233
app.WithHandler("/api/", apiHandler),
3334
app.WithAddr(cfg.Addr),
3435
)
3536
}
3637
```
3738

38-
H2C, health check at `/ping`, and HTTP middleware (recovery, request ID, request logging, CORS) are enabled by default.
39+
H2C and health check at `/ping` enabled by default. HTTP middleware is explicit — you choose what runs.
3940

4041
### CLI
4142

@@ -54,7 +55,7 @@ func main() {
5455
}
5556
```
5657

57-
Help, shell completion, and reference docs are enabled by default. Commands access shared output via `cli.Output(cmd)`.
58+
Help, shell completion, and reference docs enabled by default. Commands access shared output via `cli.Output(cmd)`.
5859

5960
## Installation
6061

@@ -70,7 +71,7 @@ Requires Go 1.24+.
7071

7172
| Package | Description |
7273
|---------|-------------|
73-
| [`app`](app/) | Service lifecycle — config, logger, db, telemetry, server, graceful shutdown |
74+
| [`app`](app/) | Service lifecycle — config, logger, telemetry, server, graceful shutdown |
7475
| [`cli`](cli/) | CLI lifecycle — root command, help, completion, version check |
7576

7677
### Server & Middleware
@@ -101,16 +102,7 @@ Requires Go 1.24+.
101102
| Package | Description |
102103
|---------|-------------|
103104
| [`config`](config/) | Configuration from files, env vars, flags, and struct defaults |
104-
| [`db`](db/) | Database client (sqlx) with connection pooling and migrations |
105105
| [`telemetry`](telemetry/) | OpenTelemetry initialization — traces and metrics via OTLP |
106-
| [`telemetry/otelhttpclient`](telemetry/otelhttpclient/) | HTTP client transport with OTel metrics |
107-
108-
### Auth
109-
110-
| Package | Description |
111-
|---------|-------------|
112-
| [`auth/oidc`](auth/oidc/) | OpenID Connect authentication with PKCE |
113-
| [`auth/audit`](auth/audit/) | Audit event logging |
114106

115107
### Data
116108

@@ -119,12 +111,6 @@ Requires Go 1.24+.
119111
| [`data/rql`](data/rql/) | REST query language — filters, pagination, sorting, search |
120112
| [`data/jsondiff`](data/jsondiff/) | JSON document diffing and reconstruction |
121113

122-
### Testing
123-
124-
| Package | Description |
125-
|---------|-------------|
126-
| [`testkit`](testkit/) | Docker test containers — Postgres, Minio, SpiceDB, Nginx, Cortex |
127-
128114
## Logging
129115

130116
Salt uses `*slog.Logger` from the Go standard library. No custom logger interface — pass `slog.Default()` or any `*slog.Logger` to packages that need it.

0 commit comments

Comments
 (0)