Wire the daemons with fx, providers in internal/sww #414

Closed
opened 2026-11-19 08:54:27 +01:00 by clawbot · 1 comment
Collaborator

sneak on #283 (comment): "immediately begin the fx work on a branch using the recommended config. let's land it on next asap."

The recommended option, from the architecture review on that issue (the ### fx section): fx with providers in internal/sww.

  • The other packages keep their Params of plain values and import neither fx nor, where they do not today, config.
  • internal/sww holds one small function per part that turns the settings into that part's Params and builds it, as newAlertQueue and newRemoteLogSender already do. fx calls them in dependency order.
  • Each background loop is one lifecycle hook, registered where its part is built.
  • This replaces newServer, loadStateFiles, the inBackground list and both serve functions.
  • The review's catches apply: fx's own event log goes through slog (stdout carries JSON lines only); RunDiscriminator(ctx, params) int (or its renamed form) stays as the entry the tests call, using fx's Start and Stop, not its signal handling; stop order is the reverse of start, so the last state write stays last; types fx resolves by (func() time.Time, io.Writer) get named types of their own.

Definition of done: go.uber.org/fx wires every daemon as above; behaviour is unchanged (every existing test passes unmodified apart from construction); fx appears only in internal/sww and the cmd/ entry points; make check passes; the PR body is under 250 words. If this is more than one PR can carry, the worker says so on this issue instead of starting.

Model: opus-5-5

sneak on https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-183071: "immediately begin the fx work on a branch using the recommended config. let's land it on next asap." The recommended option, from the architecture review on that issue (the `### fx` section): **fx with providers in `internal/sww`**. - The other packages keep their `Params` of plain values and import neither fx nor, where they do not today, `config`. - `internal/sww` holds one small function per part that turns the settings into that part's `Params` and builds it, as `newAlertQueue` and `newRemoteLogSender` already do. fx calls them in dependency order. - Each background loop is one lifecycle hook, registered where its part is built. - This replaces `newServer`, `loadStateFiles`, the `inBackground` list and both serve functions. - The review's catches apply: fx's own event log goes through `slog` (stdout carries JSON lines only); `RunDiscriminator(ctx, params) int` (or its renamed form) stays as the entry the tests call, using fx's `Start` and `Stop`, not its signal handling; stop order is the reverse of start, so the last state write stays last; types fx resolves by (`func() time.Time`, `io.Writer`) get named types of their own. Definition of done: `go.uber.org/fx` wires every daemon as above; behaviour is unchanged (every existing test passes unmodified apart from construction); fx appears only in `internal/sww` and the `cmd/` entry points; `make check` passes; the PR body is under 250 words. If this is more than one PR can carry, the worker says so on this issue instead of starting. Model: opus-5-5
Author
Collaborator

Built in #421, branch issue-414-fx-wiring.

  • fx builds and runs both daemons from providers in internal/sww. One serve hook and one run function replace both serve functions.
  • Judgement call: the nine parts waf.New builds stay in internal/waf. Moving them is the review's separate proposal "The parts are built in two places".
  • Deviations, each explained in the PR body:
    • the alert queue's and the lists' loops are registered with the state files, so that they end before the last write;
    • the remote log sender stays outside fx.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/smallwebwaf/pulls/421, branch `issue-414-fx-wiring`. - fx builds and runs both daemons from providers in `internal/sww`. One `serve` hook and one `run` function replace both serve functions. - Judgement call: the nine parts `waf.New` builds stay in `internal/waf`. Moving them is the review's separate proposal "The parts are built in two places". - Deviations, each explained in the PR body: - the alert queue's and the lists' loops are registered with the state files, so that they end before the last write; - the remote log sender stays outside fx. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/smallwebwaf#414