Skip to content

Rewriting actor state caching mechanism #1473

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

Draft
wants to merge 17 commits into
base: release-1.16
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/itests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
GOOS: linux
GOARCH: amd64
GOPROXY: https://proxy.golang.org
DAPR_CLI_VER: 1.14.0
DAPR_RUNTIME_VER: 1.14.0
DAPR_CLI_VER: 1.15.0
DAPR_RUNTIME_VER: 1.15.3
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/release-1.14/install/install.sh
DAPR_CLI_REF: ''
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To load secrets into configuration call the _AddDaprSecretStore_ extension metho
Use Dapr to run the application:

```shell
dapr run --app-id SecretStoreConfigurationProviderSample --components-path ./components/ -- dotnet run
dapr run --app-id SecretStoreConfigurationProviderSample --resources-path ./components/ -- dotnet run
```

### 2. Test the application
Expand Down
2 changes: 1 addition & 1 deletion examples/Client/ConfigurationApi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ cd examples/Client/ConfigurationApi
To run the `ConfigurationExample`, execute the following command:

```bash
dapr run --app-id configexample --components-path ./Components -- dotnet run
dapr run --app-id configexample --resources-path ./Components -- dotnet run
```

### Get Configuration
Expand Down
6 changes: 3 additions & 3 deletions examples/Client/DistributedLock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cd examples/Client/DistributedLock
In order to run the application that generates data for the workers to process, simply run the following command:

```bash
dapr run --components-path ./Components --app-id generator -- dotnet run
dapr run --resources-path ./Components --app-id generator -- dotnet run
```

This application will create a new file to process once every 10 seconds. The files are stored in `DistributedLock/tmp`.
Expand All @@ -33,8 +33,8 @@ This application will create a new file to process once every 10 seconds. The fi
In order to properly demonstrate locking, this application will be run more than once with the same App ID. However, the applications do need different ports in order to properly receive bindings. Run them with the command below:

```bash
dapr run --components-path ./Components --app-id worker --app-port 5000 -- dotnet run
dapr run --components-path ./Components --app-id worker --app-port 5001 -- dotnet run
dapr run --resources-path ./Components --app-id worker --app-port 5000 -- dotnet run
dapr run --resources-path ./Components --app-id worker --app-port 5001 -- dotnet run
```

After running the applications, they will attempt to process files. You should see output such as:
Expand Down
184 changes: 91 additions & 93 deletions src/Dapr.Actors/IDaprInteractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,110 +11,108 @@
// limitations under the License.
// ------------------------------------------------------------------------

namespace Dapr.Actors;

using System.Net.Http;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Dapr.Actors.Communication;

namespace Dapr.Actors
/// <summary>
/// Interface for interacting with Dapr runtime.
/// </summary>
internal interface IDaprInteractor
{
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Dapr.Actors.Communication;

/// <summary>
/// Interface for interacting with Dapr runtime.
/// Invokes an Actor method on Dapr without remoting.
/// </summary>
internal interface IDaprInteractor
{
/// <summary>
/// Invokes an Actor method on Dapr without remoting.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="methodName">Method name to invoke.</param>
/// <param name="jsonPayload">Serialized body.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
Task<Stream> InvokeActorMethodWithoutRemotingAsync(string actorType, string actorId, string methodName, string jsonPayload, CancellationToken cancellationToken = default);
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="methodName">Method name to invoke.</param>
/// <param name="jsonPayload">Serialized body.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
Task<Stream> InvokeActorMethodWithoutRemotingAsync(string actorType, string actorId, string methodName, string jsonPayload, CancellationToken cancellationToken = default);

/// <summary>
/// Saves state batch to Dapr.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="data">JSON data with state changes as per the Dapr spec for transaction state update.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
Task SaveStateTransactionallyAsync(string actorType, string actorId, string data, CancellationToken cancellationToken = default);
/// <summary>
/// Saves state batch to Dapr.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="data">JSON data with state changes as per the Dapr spec for transaction state update.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
Task SaveStateTransactionallyAsync(string actorType, string actorId, string data, CancellationToken cancellationToken = default);

/// <summary>
/// Saves a state to Dapr.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="keyName">Name of key to get value for.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
Task<ActorStateResponse<string>> GetStateAsync(string actorType, string actorId, string keyName, CancellationToken cancellationToken = default);
/// <summary>
/// Gets a state from Dapr.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="keyName">Name of key to get value for.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A task that represents the asynchronous operation.</returns>
Task<ActorStateResponse<string>> GetStateAsync(string actorType, string actorId, string keyName, CancellationToken cancellationToken = default);

/// <summary>
/// Invokes Actor method.
/// </summary>
/// <param name="serializersManager">Serializers manager for remoting calls.</param>
/// <param name="remotingRequestRequestMessage">Actor Request Message.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task<IActorResponseMessage> InvokeActorMethodWithRemotingAsync(ActorMessageSerializersManager serializersManager, IActorRequestMessage remotingRequestRequestMessage, CancellationToken cancellationToken = default);
/// <summary>
/// Invokes Actor method.
/// </summary>
/// <param name="serializersManager">Serializers manager for remoting calls.</param>
/// <param name="remotingRequestRequestMessage">Actor Request Message.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task<IActorResponseMessage> InvokeActorMethodWithRemotingAsync(ActorMessageSerializersManager serializersManager, IActorRequestMessage remotingRequestRequestMessage, CancellationToken cancellationToken = default);

/// <summary>
/// Register a reminder.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="reminderName">Name of reminder to register.</param>
/// <param name="data">JSON reminder data as per the Dapr spec.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task RegisterReminderAsync(string actorType, string actorId, string reminderName, string data, CancellationToken cancellationToken = default);
/// <summary>
/// Register a reminder.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="reminderName">Name of reminder to register.</param>
/// <param name="data">JSON reminder data as per the Dapr spec.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task RegisterReminderAsync(string actorType, string actorId, string reminderName, string data, CancellationToken cancellationToken = default);

/// <summary>
/// Gets a reminder.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="reminderName">Name of reminder to unregister.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> containing the response of the asynchronous HTTP operation.</returns>
Task<HttpResponseMessage> GetReminderAsync(string actorType, string actorId, string reminderName, CancellationToken cancellationToken = default);
/// <summary>
/// Gets a reminder.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="reminderName">Name of reminder to unregister.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> containing the response of the asynchronous HTTP operation.</returns>
Task<HttpResponseMessage> GetReminderAsync(string actorType, string actorId, string reminderName, CancellationToken cancellationToken = default);

/// <summary>
/// Unregisters a reminder.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="reminderName">Name of reminder to unregister.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task UnregisterReminderAsync(string actorType, string actorId, string reminderName, CancellationToken cancellationToken = default);
/// <summary>
/// Unregisters a reminder.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="reminderName">Name of reminder to unregister.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task UnregisterReminderAsync(string actorType, string actorId, string reminderName, CancellationToken cancellationToken = default);

/// <summary>
/// Registers a timer.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="timerName">Name of timer to register.</param>
/// <param name="data">JSON reminder data as per the Dapr spec.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task RegisterTimerAsync(string actorType, string actorId, string timerName, string data, CancellationToken cancellationToken = default);
/// <summary>
/// Registers a timer.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="timerName">Name of timer to register.</param>
/// <param name="data">JSON reminder data as per the Dapr spec.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task RegisterTimerAsync(string actorType, string actorId, string timerName, string data, CancellationToken cancellationToken = default);

/// <summary>
/// Unegisters a timer.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="timerName">Name of timer to register.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task UnregisterTimerAsync(string actorType, string actorId, string timerName, CancellationToken cancellationToken = default);
}
/// <summary>
/// Unegisters a timer.
/// </summary>
/// <param name="actorType">Type of actor.</param>
/// <param name="actorId">ActorId.</param>
/// <param name="timerName">Name of timer to register.</param>
/// <param name="cancellationToken">Cancels the operation.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
Task UnregisterTimerAsync(string actorType, string actorId, string timerName, CancellationToken cancellationToken = default);
}
Loading
Loading