-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64cd675
commit 75ac054
Showing
35 changed files
with
2,473 additions
and
1,929 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
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
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 |
---|---|---|
@@ -1,60 +1,64 @@ | ||
#nullable enable | ||
using System; | ||
using Orleans.Core; | ||
using Orleans.Timers; | ||
|
||
namespace Orleans.Runtime | ||
namespace Orleans.Runtime; | ||
|
||
/// <summary> | ||
/// The gateway of the <see cref="Grain"/> to the Orleans runtime. The <see cref="Grain"/> should only interact with the runtime through this interface. | ||
/// </summary> | ||
public interface IGrainRuntime | ||
{ | ||
/// <summary> | ||
/// The gateway of the <see cref="Grain"/> to the Orleans runtime. The <see cref="Grain"/> should only interact with the runtime through this interface. | ||
/// </summary> | ||
public interface IGrainRuntime | ||
{ | ||
/// <summary> | ||
/// Gets a unique identifier for the current silo. | ||
/// There is no semantic content to this string, but it may be useful for logging. | ||
/// </summary> | ||
string SiloIdentity { get; } | ||
|
||
/// <summary> | ||
/// Gets the silo address associated with this instance. | ||
/// </summary> | ||
SiloAddress SiloAddress { get; } | ||
|
||
/// <summary> | ||
/// Gets the grain factory. | ||
/// </summary> | ||
IGrainFactory GrainFactory { get; } | ||
|
||
/// <summary> | ||
/// Gets the timer registry. | ||
/// </summary> | ||
ITimerRegistry TimerRegistry { get; } | ||
|
||
|
||
/// <summary> | ||
/// Gets the service provider. | ||
/// </summary> | ||
IServiceProvider ServiceProvider { get; } | ||
|
||
/// <summary> | ||
/// Deactivates the provided grain when it becomes idle. | ||
/// </summary> | ||
/// <param name="grainContext">The grain context.</param> | ||
void DeactivateOnIdle(IGrainContext grainContext); | ||
|
||
/// <summary> | ||
/// Delays idle activation collection of the provided grain due to inactivity until at least the specified time has elapsed. | ||
/// </summary> | ||
/// <param name="grainContext">The grain context.</param> | ||
/// <param name="timeSpan">The time to delay idle activation collection for.</param> | ||
void DelayDeactivation(IGrainContext grainContext, TimeSpan timeSpan); | ||
|
||
/// <summary> | ||
/// Gets grain storage for the provided grain. | ||
/// </summary> | ||
/// <typeparam name="TGrainState">The grain state type.</typeparam> | ||
/// <param name="grainContext">The grain context.</param> | ||
/// <returns>The grain storage for the provided grain.</returns> | ||
IStorage<TGrainState> GetStorage<TGrainState>(IGrainContext grainContext); | ||
} | ||
/// Gets a unique identifier for the current silo. | ||
/// There is no semantic content to this string, but it may be useful for logging. | ||
/// </summary> | ||
string SiloIdentity { get; } | ||
|
||
/// <summary> | ||
/// Gets the silo address associated with this instance. | ||
/// </summary> | ||
SiloAddress SiloAddress { get; } | ||
|
||
/// <summary> | ||
/// Gets the grain factory. | ||
/// </summary> | ||
IGrainFactory GrainFactory { get; } | ||
|
||
/// <summary> | ||
/// Gets the timer registry. | ||
/// </summary> | ||
ITimerRegistry TimerRegistry { get; } | ||
|
||
/// <summary> | ||
/// Gets the service provider. | ||
/// </summary> | ||
IServiceProvider ServiceProvider { get; } | ||
|
||
/// <summary> | ||
/// Gets the time provider. | ||
/// </summary> | ||
TimeProvider TimeProvider => TimeProvider.System; | ||
|
||
/// <summary> | ||
/// Deactivates the provided grain when it becomes idle. | ||
/// </summary> | ||
/// <param name="grainContext">The grain context.</param> | ||
void DeactivateOnIdle(IGrainContext grainContext); | ||
|
||
/// <summary> | ||
/// Delays idle activation collection of the provided grain due to inactivity until at least the specified time has elapsed. | ||
/// </summary> | ||
/// <param name="grainContext">The grain context.</param> | ||
/// <param name="timeSpan">The time to delay idle activation collection for.</param> | ||
void DelayDeactivation(IGrainContext grainContext, TimeSpan timeSpan); | ||
|
||
/// <summary> | ||
/// Gets grain storage for the provided grain. | ||
/// </summary> | ||
/// <typeparam name="TGrainState">The grain state type.</typeparam> | ||
/// <param name="grainContext">The grain context.</param> | ||
/// <returns>The grain storage for the provided grain.</returns> | ||
IStorage<TGrainState> GetStorage<TGrainState>(IGrainContext grainContext); | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Orleans.Runtime; | ||
|
||
|
49 changes: 49 additions & 0 deletions
49
src/Orleans.Core.Abstractions/Timers/GrainTimerCreationOptions.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,49 @@ | ||
#nullable enable | ||
using System; | ||
using System.Threading; | ||
using Orleans.Concurrency; | ||
|
||
namespace Orleans.Runtime; | ||
|
||
/// <summary> | ||
/// Options for creating grain timers. | ||
/// </summary> | ||
public readonly struct GrainTimerCreationOptions() | ||
{ | ||
/// <summary> | ||
/// The amount of time to delay before the timer callback is invoked. | ||
/// Specify <see cref="Timeout.InfiniteTimeSpan"/> to prevent the timer from starting. | ||
/// Specify <see cref="TimeSpan.Zero"/> to invoke the callback promptly. | ||
/// </summary> | ||
public required TimeSpan DueTime { get; init; } | ||
|
||
/// <summary> | ||
/// The time interval between invocations of callback. | ||
/// Specify <see cref="Timeout.InfiniteTimeSpan"/> to disable periodic signaling. | ||
/// </summary> | ||
public TimeSpan Period { get; init; } = Timeout.InfiniteTimeSpan; | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether callbacks scheduled by this timer are allowed to interleave execution with other timers and grain calls. | ||
/// Defaults to <see langword="false"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// If this value is <see langword="false"/>, the timer callback will be treated akin to a grain call. If the grain scheduling this timer is reentrant | ||
/// (i.e., it has the <see cref="ReentrantAttribute"/> attributed applied to its implementation class), the timer callback will be allowed | ||
/// to interleave with other grain calls and timers regardless of the value of this property. | ||
/// If this value is <see langword="true"/>, the timer callback will be allowed to interleave with other timers and grain calls. | ||
/// </remarks> | ||
public bool Interleave { get; init; } | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether callbacks scheduled by this timer should extend the lifetime of the grain activation. | ||
/// Defaults to <see langword="false"/>. | ||
/// </summary> | ||
/// <remarks> | ||
/// If this value is <see langword="false"/>, timer callbacks will not extend a grain activation's lifetime. | ||
/// If a grain is only processing this timer's callbacks and no other messages, the grain will be collected after its idle collection period expires. | ||
/// If this value is <see langword="true"/>, timer callback will extend a grain activation's lifetime. | ||
/// If the timer period is shorter than the grain's idle collection period, the grain will not be collected due to idleness. | ||
/// </remarks> | ||
public bool KeepAlive { get; init; } | ||
} |
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
Oops, something went wrong.