Moving RuntimeContext check inside ReminderRegistry #8436
Merged
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.
Motivation
In unit testing libraries (such as OrleansTestKit) the
RuntimeContext
check for reminder-based grain calls proves very challenging.Because
RuntimeContext
uses a thread-local mechanism, it becomes non-trivial to ensure the unit test runs on the same thread as the calling code (imagine some IO-bound async behavior happening between the unit test & the Reminder call)This is related to some of the conversation going on in OrleansContrib/OrleansTestKit#134
Also related to #8387 - RuntimeContext hard to test
Proposed Fix
Move the
RuntimeContext
check into theReminderRegistry
so that it sits behind a stubbable testing seam interface instead of residing in an extension method. This fix should have very similar performance as the prior code.This change also provides more consistent w/ the Timer Registry implementation, which defers this check to inside the GrainTimer code
Alternatives considered:
ReminderOptions
to control if the RuntimeContext check occursIReminderRegistryResolver
that provides a testing seam to control this logic.cc @ReubenBond @seniorquico
Microsoft Reviewers: Open in CodeFlow