Repository navigation
fix(plugins): every default registration carries the simulated clock (#904) - #1027
Merged
Merged
Conversation
…904) RegisterDefaultPlugins spelled a PluginConfig out per registration, and fifteen of the sixty-seven left Options["time_controller"] out. The fallback every plugin takes for an absent key is a private NewTimeController(time.Now()) and it is silent by design, so a registration that forgot the key looked exactly like one that supplied it — and eleven services stamped their timestamps from the wall clock, ignoring both the time control endpoints and the clock a replay sets per event. The config is now built in one place, pluginWiring.register, and the registrations are a table of {plugin, name, extra} in the original order with the original error-wrap names. A registration can no longer spell its own config out, which is what made the omission invisible at each call site. A nil *TimeController is left out of the map rather than stored: every plugin reads the value with a type assertion that succeeds for a typed nil and would hand the plugin a clock that panics on first use, where an absent key takes the documented fallback instead. Kinesis needed a second fix. generateKinesisSeqNo called time.Now() from a function with no receiver, so it could not reach any plugin's clock however that clock was supplied — and a SequenceNumber is observable, reported by PutRecord and PutRecords and echoed back by GetRecords. It now takes the instant as a parameter and both call sites pass the plugin's clock. The new test asserts exact equality against a stopped clock for each of the eleven plugins whose registration used to omit it, through the server rather than through a hand-initialized plugin, plus that POST /v1/control/time reaches two of them. All eleven fail against the parent commit. The four remaining registrations of the fifteen — Tagging, Health, Price List and the API Gateway proxy — have no clock field at all, so the option is a deliberate no-op there. #886's workaround, which re-registered SES v2 by hand with the server's clock in order to assert a whole MessageId, is deleted. Closes #904.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RegisterDefaultPlugins spelled a PluginConfig out per registration, and fifteen
of the sixty-seven left Options["time_controller"] out. The fallback every
plugin takes for an absent key is a private NewTimeController(time.Now()) and
it is silent by design, so a registration that forgot the key looked exactly
like one that supplied it — and eleven services stamped their timestamps from
the wall clock, ignoring both the time control endpoints and the clock a replay
sets per event.
The config is now built in one place, pluginWiring.register, and the
registrations are a table of {plugin, name, extra} in the original order with
the original error-wrap names. A registration can no longer spell its own
config out, which is what made the omission invisible at each call site.
A nil *TimeController is left out of the map rather than stored: every plugin
reads the value with a type assertion that succeeds for a typed nil and would
hand the plugin a clock that panics on first use, where an absent key takes the
documented fallback instead.
Kinesis needed a second fix. generateKinesisSeqNo called time.Now() from a
function with no receiver, so it could not reach any plugin's clock however
that clock was supplied — and a SequenceNumber is observable, reported by
PutRecord and PutRecords and echoed back by GetRecords. It now takes the
instant as a parameter and both call sites pass the plugin's clock.
The new test asserts exact equality against a stopped clock for each of the
eleven plugins whose registration used to omit it, through the server rather
than through a hand-initialized plugin, plus that POST /v1/control/time reaches
two of them. All eleven fail against the parent commit. The four remaining
registrations of the fifteen — Tagging, Health, Price List and the API Gateway
proxy — have no clock field at all, so the option is a deliberate no-op there.
#886's workaround, which re-registered SES v2 by hand with the server's clock
in order to assert a whole MessageId, is deleted.
Closes #904.
Verification
The nine-command gate is clean:
gofmt/go build/go vet,golangci-lint run ./...,make test,GOTOOLCHAIN=go1.26.6 make test,GOTOOLCHAIN=go1.26.6 make coverage, the four docs targets,npm --prefix docs run build, and the e2e suite. Coverage holds the baseline at 85.0% emulator / 84.5% total.The premise corrections behind this change are recorded on the issue: only eleven of the fifteen have a clock field at all, the Kinesis bypass, the three uncounted callers of
RegisterDefaultPlugins(including the debug UI, whose zero-time clock the eleven now inherit), and why AC 4 is answered by central wiring rather than by makingInitializefail.