From the architecture review: "Three constructors take their arguments by position" (#283 (comment)) and two of the shorter notes under "The smaller packages" (#283 (comment)). Approved for building: #283 (comment). The code was read at 809d266 on next. Line numbers are that commit's.
Three small changes to how parts are built, in one PR. The third of the review's three constructors, metrics.New, is part of the issue that gives metrics one Params: #438.
What is there
Fifteen constructors under internal/ take one Params struct. Two more take their arguments by position:
requestlog holds three things: the log line types and their writers, the words a decision is logged with, and the process's own slog logger.
geojs.GeoJS copies each of its six Params fields into a field of its own (internal/geojs/geojs.go). The three other types that ask an outside service (reputation.DNSBL, reputation.AbuseIPDB, routewatch.Client) keep params whole.
Why it matters
CODE_STYLEGUIDE_GO.md asks for a Params struct even for one argument: arguments by position make a call site unreadable and are easy to swap.
GO_HTTP_SERVER_CONVENTIONS.md gives the process logger a package of its own. requestlog would then be only the request log.
Four types of the same kind should read the same way.
What changes
ratelimit.New takes a ratelimit.Params that holds the limits and the most clients.
The process logger moves out of requestlog into a package of its own, where its constructor is New(Params). Default name: internal/processlog. Changing the name later is one commit.
geojs.GeoJS keeps its params whole, as the other three do.
What stays
What each constructor builds, and every log line.
requestlog.FormatTime, which the process logger uses for its times, stays in requestlog.
The issue that ends GeoJS's asks at the stop (#439) edits the same GeoJS struct: whichever is built second rebases.
The SQLite state store (#217) also changes how ratelimit.New is called. If a PR for it is open when this is picked up, leave ratelimit.New to that PR and say so here.
Done when
ratelimit.New and the process logger's constructor each take one Params;
requestlog holds no process logger, and SPEC's package list under "Architecture" names the new package;
behaviour is unchanged: every existing test passes with no assertion changed;
make check passes;
the PR body lists every new package, type and field name. Each says what the thing is to a reader of that one file, the standard of the symbol names audit (#213).
Model: fable-5-2
From the architecture review: "Three constructors take their arguments by position" (https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-173850) and two of the shorter notes under "The smaller packages" (https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-173847). Approved for building: https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-183550. The code was read at `809d266` on `next`. Line numbers are that commit's.
Three small changes to how parts are built, in one PR. The third of the review's three constructors, `metrics.New`, is part of the issue that gives `metrics` one `Params`: https://git.eeqj.de/sneak/smallwebwaf/issues/438.
### What is there
- Fifteen constructors under `internal/` take one `Params` struct. Two more take their arguments by position:
- `ratelimit.New(limits Limits, maxClients int)` (`internal/ratelimit/ratelimit.go:163`);
- `requestlog.NewProcessLogger(w io.Writer, instanceName string, level slog.Level)` (`internal/requestlog/requestlog.go:309`).
- `requestlog` holds three things: the log line types and their writers, the words a decision is logged with, and the process's own `slog` logger.
- `geojs.GeoJS` copies each of its six `Params` fields into a field of its own (`internal/geojs/geojs.go`). The three other types that ask an outside service (`reputation.DNSBL`, `reputation.AbuseIPDB`, `routewatch.Client`) keep `params` whole.
### Why it matters
- `CODE_STYLEGUIDE_GO.md` asks for a `Params` struct even for one argument: arguments by position make a call site unreadable and are easy to swap.
- `GO_HTTP_SERVER_CONVENTIONS.md` gives the process logger a package of its own. `requestlog` would then be only the request log.
- Four types of the same kind should read the same way.
### What changes
- `ratelimit.New` takes a `ratelimit.Params` that holds the limits and the most clients.
- The process logger moves out of `requestlog` into a package of its own, where its constructor is `New(Params)`. Default name: `internal/processlog`. Changing the name later is one commit.
- `geojs.GeoJS` keeps its `params` whole, as the other three do.
### What stays
- What each constructor builds, and every log line.
- `requestlog.FormatTime`, which the process logger uses for its times, stays in `requestlog`.
- The issue that ends GeoJS's asks at the stop (https://git.eeqj.de/sneak/smallwebwaf/issues/439) edits the same `GeoJS` struct: whichever is built second rebases.
- The SQLite state store (https://git.eeqj.de/sneak/smallwebwaf/issues/217) also changes how `ratelimit.New` is called. If a PR for it is open when this is picked up, leave `ratelimit.New` to that PR and say so here.
### Done when
- `ratelimit.New` and the process logger's constructor each take one `Params`;
- `requestlog` holds no process logger, and SPEC's package list under "Architecture" names the new package;
- behaviour is unchanged: every existing test passes with no assertion changed;
- `make check` passes;
- the PR body lists every new package, type and field name. Each says what the thing is to a reader of that one file, the standard of the symbol names audit (https://git.eeqj.de/sneak/smallwebwaf/issues/213).
Model: fable-5-2
clawbot
self-assigned this 2026-11-19 17:14:41 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
From the architecture review: "Three constructors take their arguments by position" (#283 (comment)) and two of the shorter notes under "The smaller packages" (#283 (comment)). Approved for building: #283 (comment). The code was read at
809d266onnext. Line numbers are that commit's.Three small changes to how parts are built, in one PR. The third of the review's three constructors,
metrics.New, is part of the issue that givesmetricsoneParams: #438.What is there
internal/take oneParamsstruct. Two more take their arguments by position:ratelimit.New(limits Limits, maxClients int)(internal/ratelimit/ratelimit.go:163);requestlog.NewProcessLogger(w io.Writer, instanceName string, level slog.Level)(internal/requestlog/requestlog.go:309).requestlogholds three things: the log line types and their writers, the words a decision is logged with, and the process's ownsloglogger.geojs.GeoJScopies each of its sixParamsfields into a field of its own (internal/geojs/geojs.go). The three other types that ask an outside service (reputation.DNSBL,reputation.AbuseIPDB,routewatch.Client) keepparamswhole.Why it matters
CODE_STYLEGUIDE_GO.mdasks for aParamsstruct even for one argument: arguments by position make a call site unreadable and are easy to swap.GO_HTTP_SERVER_CONVENTIONS.mdgives the process logger a package of its own.requestlogwould then be only the request log.What changes
ratelimit.Newtakes aratelimit.Paramsthat holds the limits and the most clients.requestloginto a package of its own, where its constructor isNew(Params). Default name:internal/processlog. Changing the name later is one commit.geojs.GeoJSkeeps itsparamswhole, as the other three do.What stays
requestlog.FormatTime, which the process logger uses for its times, stays inrequestlog.GeoJSstruct: whichever is built second rebases.ratelimit.Newis called. If a PR for it is open when this is picked up, leaveratelimit.Newto that PR and say so here.Done when
ratelimit.Newand the process logger's constructor each take oneParams;requestlogholds no process logger, and SPEC's package list under "Architecture" names the new package;make checkpasses;Model: fable-5-2