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

Avoid changing soon-to-be-deprecated RegisterTimer method return type #9020

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Orleans.Core.Abstractions/Core/Grain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected Grain(IGrainContext grainContext, IGrainRuntime? grainRuntime = null)
/// <param name="period">Period of subsequent timer ticks.</param>
/// <returns>Handle for this Timer.</returns>
/// <seealso cref="IDisposable"/>
protected IGrainTimer RegisterTimer(Func<object?, Task> asyncCallback, object? state, TimeSpan dueTime, TimeSpan period)
protected IDisposable RegisterTimer(Func<object?, Task> asyncCallback, object? state, TimeSpan dueTime, TimeSpan period)
{
if (asyncCallback == null)
throw new ArgumentNullException(nameof(asyncCallback));
Expand Down
4 changes: 2 additions & 2 deletions src/Orleans.Core.Abstractions/Timers/ITimerRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface ITimerRegistry
/// Specify <see cref="System.Threading.Timeout.InfiniteTimeSpan"/> to disable periodic signaling.
/// </param>
/// <returns>
/// An <see cref="IGrainTimer"/> instance which represents the timer.
/// An <see cref="IDisposable"/> instance which represents the timer.
/// </returns>
IGrainTimer RegisterTimer(IGrainContext grainContext, Func<object?, Task> callback, object? state, TimeSpan dueTime, TimeSpan period);
IDisposable RegisterTimer(IGrainContext grainContext, Func<object?, Task> callback, object? state, TimeSpan dueTime, TimeSpan period);
}
2 changes: 1 addition & 1 deletion src/Orleans.Runtime/Timers/TimerRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal class TimerRegistry(ILoggerFactory loggerFactory, TimeProvider timeProv
private readonly ILogger _timerLogger = loggerFactory.CreateLogger<GrainTimer>();
private readonly TimeProvider _timeProvider = timeProvider;

public IGrainTimer RegisterTimer(IGrainContext grainContext, Func<object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period)
public IDisposable RegisterTimer(IGrainContext grainContext, Func<object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period)
{
var timer = new GrainTimer(grainContext, _timerLogger, asyncCallback, state, _timeProvider);
grainContext?.GetComponent<IGrainTimerRegistry>().OnTimerCreated(timer);
Expand Down
4 changes: 2 additions & 2 deletions test/Grains/TestInternalGrains/TimerGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public Task StartTimer(string name, TimeSpan delay)
{
logger.LogInformation("StartTimer Name={Name} Delay={Delay}", name, delay);
if (timer is not null) throw new InvalidOperationException("Expected timer to be null");
this.timer = base.RegisterTimer(TimerTick, name, delay, Constants.INFINITE_TIMESPAN); // One shot timer
this.timer = (IGrainTimer)base.RegisterTimer(TimerTick, name, delay, Constants.INFINITE_TIMESPAN); // One shot timer
this.timerName = name;

return Task.CompletedTask;
Expand All @@ -169,7 +169,7 @@ public Task StartTimer(string name, TimeSpan delay, string operationType)
logger.LogInformation("StartTimer Name={Name} Delay={Delay}", name, delay);
if (timer is not null) throw new InvalidOperationException("Expected timer to be null");
var state = Tuple.Create<string, object>(operationType, name);
this.timer = base.RegisterTimer(TimerTickAdvanced, state, delay, Constants.INFINITE_TIMESPAN); // One shot timer
this.timer = (IGrainTimer)base.RegisterTimer(TimerTickAdvanced, state, delay, Constants.INFINITE_TIMESPAN); // One shot timer
this.timerName = name;

return Task.CompletedTask;
Expand Down
Loading