(bugfix): get dapr stete empty result should be not found error

This commit is contained in:
Maksym Sadovnychyy 2024-11-14 18:27:05 +01:00
parent d623e7c0b7
commit 7ab3e848ba
2 changed files with 6 additions and 3 deletions

View File

@ -11,7 +11,7 @@ public interface IDaprPublisherService {
}
public interface IDaprStateStoreService {
Task<Result> SaveStateAsync<T>(string storeName, string key, T value);
Task<Result> SetStateAsync<T>(string storeName, string key, T value);
Task<Result<T?>> GetStateAsync<T>(string storeName, string key);
Task<Result> DeleteStateAsync(string storeName, string key);
}
@ -56,7 +56,7 @@ public class DaprService : IDaprPublisherService, IDaprStateStoreService {
/// <param name="key"></param>
/// <param name="value"></param>
/// <returns></returns>
public async Task<Result> SaveStateAsync<T>(string storeName, string key, T value) {
public async Task<Result> SetStateAsync<T>(string storeName, string key, T value) {
try {
await _client.SaveStateAsync(storeName, key, value);
return Result.Ok();
@ -77,6 +77,9 @@ public class DaprService : IDaprPublisherService, IDaprStateStoreService {
public async Task<Result<T?>> GetStateAsync<T>(string storeName, string key) {
try {
var state = await _client.GetStateAsync<T?>(storeName, key);
if (state == null)
return Result<T?>.NotFound(default, $"State from the store {storeName} with the {key} not found.");
return Result<T?>.Ok(state);
}
catch (Exception ex) {

View File

@ -7,7 +7,7 @@
<!-- NuGet package metadata -->
<PackageId>MaksIT.Core.Dapr</PackageId>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<Authors>Maksym Sadovnychyy</Authors>
<Company>MAKS-IT</Company>
<Product>MaksIT.Core.Dapr</Product>