diff --git a/src/SlimData/Endpoints.cs b/src/SlimData/Endpoints.cs index 8d2e9f93..a056d18e 100644 --- a/src/SlimData/Endpoints.cs +++ b/src/SlimData/Endpoints.cs @@ -5,6 +5,10 @@ namespace SlimData; + +[MemoryPackable] +public partial record QueueItemStatus(string Id, int HttpCode); + public class Endpoints { public delegate Task RespondDelegate(IRaftCluster cluster, SlimPersistentState provider, @@ -178,9 +182,6 @@ public static async Task ListLeftPushCommand(SlimPersistentState provider, strin await cluster.ReplicateAsync(logEntry, source.Token); } - [MemoryPackable] - public partial record QueueItemStatus(string Id, int HttpCode); - public static Task ListSetQueueItemStatus(HttpContext context) { return DoAsync(context, async (cluster, provider, source) => diff --git a/src/SlimData/ListItems.cs b/src/SlimData/ListItems.cs index cd9a1bcb..5f020969 100644 --- a/src/SlimData/ListItems.cs +++ b/src/SlimData/ListItems.cs @@ -1,5 +1,4 @@ -using System.Text.Json.Serialization; -using MemoryPack; +using MemoryPack; namespace SlimData; diff --git a/src/SlimFaas/Database/DatabaseMockService.cs b/src/SlimFaas/Database/DatabaseMockService.cs index c6581ba6..738c73b3 100644 --- a/src/SlimFaas/Database/DatabaseMockService.cs +++ b/src/SlimFaas/Database/DatabaseMockService.cs @@ -105,7 +105,7 @@ public Task ListLengthAsync(string key) return Task.FromResult(list.Count); } - public async Task ListSetQueueItemStatus(string key, List queueItemStatus) + public async Task ListSetQueueItemStatus(string key, List queueItemStatus) { await Task.Delay(100); } diff --git a/src/SlimFaas/Database/IDatabaseService.cs b/src/SlimFaas/Database/IDatabaseService.cs index 2398d124..f7846788 100644 --- a/src/SlimFaas/Database/IDatabaseService.cs +++ b/src/SlimFaas/Database/IDatabaseService.cs @@ -11,5 +11,5 @@ public interface IDatabaseService Task ListLeftPushAsync(string key, byte[] field); Task> ListRightPopAsync(string key, int count = 1); Task ListLengthAsync(string key); - Task ListSetQueueItemStatus(string key, List queueItemStatus); + Task ListSetQueueItemStatus(string key, List queueItemStatus); } diff --git a/src/SlimFaas/Database/ISlimFaasQueue.cs b/src/SlimFaas/Database/ISlimFaasQueue.cs index 30794601..a9bf0e00 100644 --- a/src/SlimFaas/Database/ISlimFaasQueue.cs +++ b/src/SlimFaas/Database/ISlimFaasQueue.cs @@ -6,6 +6,6 @@ public interface ISlimFaasQueue { Task EnqueueAsync(string key, byte[] message); Task> DequeueAsync(string key, long count = 1); - Task ListSetQueueItemStatusAsync(string key, List queueItemStatus); + Task ListSetQueueItemStatusAsync(string key, List queueItemStatus); public Task CountAsync(string key); } diff --git a/src/SlimFaas/Database/SlimDataService.cs b/src/SlimFaas/Database/SlimDataService.cs index 195fc3c8..db50c662 100644 --- a/src/SlimFaas/Database/SlimDataService.cs +++ b/src/SlimFaas/Database/SlimDataService.cs @@ -166,12 +166,12 @@ private async Task> DoListRightPopAsync(string key, int count = } } - public async Task ListSetQueueItemStatus(string key, List queueItemStatus) + public async Task ListSetQueueItemStatus(string key, List queueItemStatus) { await Retry.Do(() => DoListSetQueueItemStatus(key, queueItemStatus), _retryInterval, logger, MaxAttemptCount); } - private async Task DoListSetQueueItemStatus(string key, List queueItemStatus) + private async Task DoListSetQueueItemStatus(string key, List queueItemStatus) { EndPoint endpoint = await GetAndWaitForLeader(); diff --git a/src/SlimFaas/Database/SlimFaasQueue.cs b/src/SlimFaas/Database/SlimFaasQueue.cs index 868e330a..8ffbc0df 100644 --- a/src/SlimFaas/Database/SlimFaasQueue.cs +++ b/src/SlimFaas/Database/SlimFaasQueue.cs @@ -17,7 +17,7 @@ public async Task> DequeueAsync(string key, long count = 1) return data; } - public async Task ListSetQueueItemStatusAsync(string key, List queueItemStatus) => await databaseService.ListSetQueueItemStatus($"{KeyPrefix}{key}", queueItemStatus); + public async Task ListSetQueueItemStatusAsync(string key, List queueItemStatus) => await databaseService.ListSetQueueItemStatus($"{KeyPrefix}{key}", queueItemStatus); public async Task CountAsync(string key) => await databaseService.ListLengthAsync($"{KeyPrefix}{key}"); } diff --git a/src/SlimFaas/SlimWorker.cs b/src/SlimFaas/SlimWorker.cs index a87e6c4c..1524af1a 100644 --- a/src/SlimFaas/SlimWorker.cs +++ b/src/SlimFaas/SlimWorker.cs @@ -139,7 +139,7 @@ private async Task ManageProcessingTasksAsync(ISlimFaasQueue slimFaasQueue, { processingTasks.Add(functionDeployment, new List()); } - var queueItemStatusList = new List(); + var queueItemStatusList = new List(); List httpResponseMessagesToDelete = new(); foreach (RequestToWait processing in processingTasks[functionDeployment]) { @@ -160,11 +160,11 @@ private async Task ManageProcessingTasksAsync(ISlimFaasQueue slimFaasQueue, processing.CustomRequest.Method, processing.CustomRequest.Path, processing.CustomRequest.Query, httpResponseMessage.StatusCode); httpResponseMessagesToDelete.Add(processing); - queueItemStatusList.Add(new Endpoints.QueueItemStatus(processing.id, statusCode)); + queueItemStatusList.Add(new QueueItemStatus(processing.id, statusCode)); } catch (Exception e) { - queueItemStatusList.Add(new Endpoints.QueueItemStatus(processing.id, 500)); + queueItemStatusList.Add(new QueueItemStatus(processing.id, 500)); httpResponseMessagesToDelete.Add(processing); logger.LogWarning("Request Error: {Message} {StackTrace}", e.Message, e.StackTrace); historyHttpService.SetTickLastCall(functionDeployment, DateTime.UtcNow.Ticks); diff --git a/tests/SlimFaas.Tests/SlimProxyMiddlewareTests.cs b/tests/SlimFaas.Tests/SlimProxyMiddlewareTests.cs index e39b4e49..f3b8e07d 100644 --- a/tests/SlimFaas.Tests/SlimProxyMiddlewareTests.cs +++ b/tests/SlimFaas.Tests/SlimProxyMiddlewareTests.cs @@ -77,7 +77,7 @@ internal class MemorySlimFaasQueue : ISlimFaasQueue public Task CountAsync(string key) => throw new NotImplementedException(); - public Task ListSetQueueItemStatusAsync(string key, List queueItemStatus) => throw new NotImplementedException(); + public Task ListSetQueueItemStatusAsync(string key, List queueItemStatus) => throw new NotImplementedException(); public async Task EnqueueAsync(string key, byte[] message) => await Task.Delay(100); }