Skip to content

How to observe/wait for a Grain state #7439

Answered by ReubenBond
burgerTo asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Toni,

One way to accomplish this is via a callback: your waiter grain can call the observee grain with await targetGrain.CallMeWhenX(IWaiterGrain) and your observee grain can issue a callback when it's time.
Another option is to poll / long poll: Task<Status> PollForX() which can return after 5 seconds with a timeout status if the condition is not met (mark it as [AlwaysInterleave] so that other methods can execute while it's running).
A third option is a hybrid of those two: registering a callback periodically. The benefit of that approach is that it doesn't require any persistence in the observee.
Another option is to use streams: the observee can push a notification that the conditi…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@burgerTo
Comment options

@ReubenBond
Comment options

Answer selected by burgerTo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants