Move the scan module to brother, ADR 0467 clause 1: the code unchanged in what it does (issue 1453)

This commit is contained in:
2026-10-20 21:06:24 +02:00
parent 809dd76973
commit 4a892ee29d
27 changed files with 18 additions and 18 deletions
@@ -1,4 +1,4 @@
# scan — scan a document, crop it, file it, say so
# brother — scan a document, crop it, file it, say so
Built for issue 1440 as novox/hq ADR 0464 decides. It scans the glass of a network scanner (any scanner that
speaks eSCL, also called AirScan or Mopria), cuts the document out of the lid's white, files it as a one-page PDF
@@ -47,7 +47,7 @@ makes it (mode 0755) when it files the first scan.
## The event
`scan.added`, on the wire `mesh.mod.scan.event.scan.added`; a consumer declares `scan.scan.added`. Its body:
`scan.added`, on the wire `mesh.mod.brother.event.scan.added`; a consumer declares `brother.scan.added`. Its body:
`path`, `node`, `bytes`, `sha256`, `width-mm`, `height-mm`, `resolution` (dpi, as the scanner gave it),
`color-mode`, `cropped`, `scanned-at` (RFC 3339, UTC).
@@ -62,5 +62,5 @@ Each directory or archive this module declares says how it treats a file it did
## Tests
The unit tests use the captured answers of a real scanner (`cmd/scan/testdata/escl`, captured 2026-10-20) served
The unit tests use the captured answers of a real scanner (`cmd/brother/testdata/escl`, captured 2026-10-20) served
by a test HTTP server; no test reaches a scanner.
@@ -10,7 +10,7 @@ import (
)
func main() {
if err := stdio.Serve("", tools(os.Getenv("SCAN_SETTINGS"), emit, time.Now)); err != nil {
if err := stdio.Serve("", tools(os.Getenv("BROTHER_SETTINGS"), emit, time.Now)); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
@@ -86,11 +86,11 @@ func TestTheConfigReachesTheCodeThroughItsSettingsFile(t *testing.T) {
env := ""
for _, a := range m.Build.Artifacts {
if a["kind"] == "bundle" {
env, _ = a["env"].(map[string]any)["SCAN_SETTINGS"].(string)
env, _ = a["env"].(map[string]any)["BROTHER_SETTINGS"].(string)
}
}
if env != "${dir:state}/settings.json" {
t.Errorf("SCAN_SETTINGS = %q", env)
t.Errorf("BROTHER_SETTINGS = %q", env)
}
raw, err := os.ReadFile(filepath.Join("..", "..", "files", "settings.json"))
if err != nil {
@@ -9,8 +9,8 @@ import (
"time"
)
// EventAdded is the module's event: a scan was filed (ADR 0464). Consumers declare scan.scan.added; it
// travels as mesh.mod.scan.event.scan.added. It names the file and never carries the image.
// EventAdded is the module's event: a scan was filed (ADR 0464). Consumers declare brother.scan.added; it
// travels as mesh.mod.brother.event.scan.added. It names the file and never carries the image.
const EventAdded = "scan.added"
// Emitter says an event on the bus under a message id, so a repeated publish is kept to one (ADR 0436).
@@ -1,4 +1,4 @@
// Package main is the scan module's Go tools bundle (novox/hq ADR 0464, issue 1440): it scans the glass of a
// Package main is the brother module's Go tools bundle (novox/hq ADR 0464, issue 1440): it scans the glass of a
// network scanner over eSCL, crops the document, files it as a one-page PDF in a folder and says so on the bus.
// A scan happens when a tool is called; the module runs no process of its own.
package main
@@ -25,12 +25,12 @@ type Settings struct {
Crop bool
}
// LoadSettings reads settings.json (the file named by SCAN_SETTINGS) and lays the defaults under it. A missing
// LoadSettings reads settings.json (the file named by BROTHER_SETTINGS) and lays the defaults under it. A missing
// or unreadable file is an error that names it; an unset scanner or folder is Missing's to say.
func LoadSettings(path string) (Settings, error) {
s := Settings{Resolution: 300, ColorMode: "color", Crop: true}
if path == "" {
return s, fmt.Errorf("SCAN_SETTINGS names no settings file: the module's config does not reach the code")
return s, fmt.Errorf("BROTHER_SETTINGS names no settings file: the module's config does not reach the code")
}
raw, err := os.ReadFile(path)
if err != nil {
@@ -71,6 +71,6 @@ func (s Settings) Missing() error {
if len(unset) == 0 {
return nil
}
return fmt.Errorf("config value %s is not set: the operator gives it with the config verb for the scan module on this node",
return fmt.Errorf("config value %s is not set: the operator gives it with the config verb for the brother module on this node",
strings.Join(unset, " and "))
}

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 110 KiB

@@ -1,4 +1,4 @@
module scan
module brother
go 1.26.0
@@ -1,5 +1,5 @@
{
"module": "scan",
"module": "brother",
"version": "1",
"emits": [
"scan.added"
@@ -83,13 +83,13 @@
"kind": "bundle",
"language": "go",
"system": "arch",
"from": "cmd/scan",
"binary": "scan",
"from": "cmd/brother",
"binary": "brother",
"loads": [
"scan"
"brother"
],
"env": {
"SCAN_SETTINGS": "${dir:state}/settings.json"
"BROTHER_SETTINGS": "${dir:state}/settings.json"
}
},
{