-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correct the double call to OnActivateAsync on IRemindable grains
Test grain for tracking OnActivateAsync call count Test OnActivateAsync is only called once
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
38 changes: 38 additions & 0 deletions
38
test/OrleansTestKit.Tests/Grains/ActivationCountWithReminder.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Orleans.Runtime; | ||
using Orleans.Streams; | ||
|
||
namespace TestGrains; | ||
|
||
public sealed class ActivationCountWithReminder : Grain, IGrainWithIntegerKey, IRemindable | ||
{ | ||
private int _activationCount; | ||
|
||
public override Task OnActivateAsync(CancellationToken cancellationToken) | ||
{ | ||
_activationCount++; | ||
return base.OnActivateAsync(cancellationToken); | ||
} | ||
|
||
public Task<int> GetActivationCount() => Task.FromResult(_activationCount); | ||
|
||
|
||
Task IRemindable.ReceiveReminder(string reminderName, TickStatus status) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
public Task RegisterReminder(string reminderName, TimeSpan dueTime, TimeSpan period) | ||
{ | ||
return this.RegisterOrUpdateReminder(reminderName, dueTime, period); | ||
} | ||
|
||
public async Task UnregisterReminder(string reminderName) | ||
{ | ||
var reminder = await this.GetReminder(reminderName); | ||
|
||
if (reminder != null) | ||
{ | ||
await this.UnregisterReminder(reminder); | ||
} | ||
} | ||
} |
This file contains 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