-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: shared clock #1416
Core: shared clock #1416
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1416 +/- ##
=============================================
- Coverage 67.61% 10.08% -57.53%
- Complexity 0 452 +452
=============================================
Files 719 719
Lines 15936 15957 +21
Branches 1043 1044 +1
=============================================
- Hits 10775 1610 -9165
- Misses 4687 14260 +9573
+ Partials 474 87 -387
Continue to review full report at Codecov.
|
@@ -47,28 +48,14 @@ public DefaultServiceExtensionContext(TypeManager typeManager, Monitor monitor, | |||
registerService(TypeManager.class, typeManager); | |||
registerService(Monitor.class, monitor); | |||
registerService(Telemetry.class, telemetry); | |||
registerService(Clock.class, Clock.systemUTC()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless there is a good reason to the contrary we should provide the clock with a @Provider(isDefault=true)
-annotated factory method in the DefaultServicesExtension
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasons for this are:
- to provide a utility method
ServiceExtensionContext#getClock
so that extensions don't need to inject a clock service. If we move the default clock toDefaultServicesExtension
, we can't have such a utility method, since we need the dependency resolver to start extensions in the right order. - that the clock is a common service just like
TypeManager
,Monitor
andTelemetry
, and there's no obvious reason to manage it differently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff @algattik. I'd like to have a Decision Record since it is important to have this approach documented and everyone aware across the codebase.
Given the conflict issue, that could be done in a subsequent PR, even though it would have been better to commit the DR first.
@juliapampus no, this is a pure "internal utils" change and does not affect any contracts or behaviours |
Great point, I've updated the parent issue to add the need for a DR, and removed the "Closes" comment from this PR. I'll do a DR next. |
6c93f72
to
e218c47
Compare
* Feature/1364/284 clock (#286) * Checkstyle * Update CHANGELOG.md * Moved default clock to DefaultServicesExtension * Update DefaultServiceExtensionContext.java * Update SqlContractNegotiationStoreExtensionTest.java * Update AbstractMultipartDispatcherIntegrationTest.java * Revert "Update AbstractMultipartDispatcherIntegrationTest.java" This reverts commit 1ebb12f. * Revert "Update SqlContractNegotiationStoreExtensionTest.java" This reverts commit af4613b. * Revert "Update DefaultServiceExtensionContext.java" This reverts commit 3798770. * Revert "Moved default clock to DefaultServicesExtension" This reverts commit 7a9fa08. * Update ContractNegotiationIntegrationTest.java * Update ContractNegotiationIntegrationTest.java
What this PR changes/adds
Use a mockable
Clock
to get the time.Removes calls to
Instant.now()
,new Date()
,System.currentTimeMillis()
from production code.Why it does that
Further notes
DefaultServiceExtensionContext
to the interfaceDataPlaneInstance
contract to return null instead of 0 for emptylastActive
time.nbf
: in discussion with BenrollbackState
method in ContractNegotiation and TransferProcess, as it's unused and violates state machine contract.ContractServiceExtension
Linked Issue(s)
Contributes to #1364 (a decision record will also be provided)
Checklist
no-changelog
)