Skip to content
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

Add Now() method to all scope interfaces. #141

Open
1 of 6 tasks
jmalloc opened this issue Jan 22, 2021 · 2 comments · Fixed by #143
Open
1 of 6 tasks

Add Now() method to all scope interfaces. #141

jmalloc opened this issue Jan 22, 2021 · 2 comments · Fixed by #143
Labels
needs adr The changes discussed require an ADR
Milestone

Comments

@jmalloc
Copy link
Member

jmalloc commented Jan 22, 2021

The current time is something you need to obtain often in the handler. We've hit a real requirement for this when writing a ProjectionMessageHandler.Compact() implementation that needs to remove data that is older than some threshold.

While in general I do not want to make the engine responsible for providing every possible dependency to the handlers, the fact that dogmatiq/testkit lets you scale/advance time artificially means that we do need some way to query the engine for the time it "thinks" it is.

Edit: I'm not sure we neccessarily want to add it to all of these interfaces, but I have put as asterisk next to those that I think probably need it most.

  • AggregateCommandScope
  • ProcessEventScope
  • ProcessTimeoutScope
  • IntegrationCommandScope
  • ProjectionEventScope
  • ProjectionCompactScope
@jmalloc jmalloc added this to the 1.0.0 milestone Feb 8, 2021
@jmalloc
Copy link
Member Author

jmalloc commented Feb 8, 2021

After discussing with @danilvpetrov and @koden-km we have decided only to implement ProjectionCompactScope.Now() until we have some concrete use cases for the others.

@jmalloc jmalloc reopened this Nov 30, 2023
@jmalloc jmalloc added needs adr The changes discussed require an ADR undecided Further discussion is required to how (or whether) to proceed labels Aug 7, 2024
@jmalloc
Copy link
Member Author

jmalloc commented Aug 21, 2024

This issue has come up again in a concrete use case at cwx. TL;DR, an aggregate implementation is using time.Now() and it is therefore hard to assert about an exact timestamp in testkit. I think we should go ahead with adding Now() to all scopes.

@jmalloc jmalloc removed the undecided Further discussion is required to how (or whether) to proceed label Aug 21, 2024
@jmalloc jmalloc changed the title Consider adding Now() method to scope interfaces. Add Now() method to all scope interfaces. Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs adr The changes discussed require an ADR
Projects
Development

Successfully merging a pull request may close this issue.

1 participant