From 8294a58671a70e0c0cb2e6dd9343de2f2e6558e6 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Sun, 16 Jul 2017 18:30:47 +0800 Subject: [PATCH] rename sentmessage to publishedmessage. --- .../IQueueExecutor.Publish.Base.cs | 16 ++++++---------- src/DotNetCore.CAP/IStorageConnection.cs | 14 ++++++-------- src/DotNetCore.CAP/IStorageTransaction.cs | 4 ++-- ...{CapSentMessage.cs => CapPublishedMessage.cs} | 15 +++++++-------- .../Processor/States/IState.Enqueued.cs | 2 +- .../Processor/States/IState.Failed.cs | 2 +- .../Processor/States/IState.Processing.cs | 2 +- .../Processor/States/IState.Scheduled.cs | 2 +- .../Processor/States/IState.Succeeded.cs | 2 +- src/DotNetCore.CAP/Processor/States/IState.cs | 2 +- .../Processor/States/IStateChanger.Default.cs | 2 +- .../Processor/States/IStateChanger.Extensions.cs | 2 +- .../Processor/States/IStateChanger.cs | 2 +- 13 files changed, 30 insertions(+), 37 deletions(-) rename src/DotNetCore.CAP/Models/{CapSentMessage.cs => CapPublishedMessage.cs} (63%) diff --git a/src/DotNetCore.CAP/IQueueExecutor.Publish.Base.cs b/src/DotNetCore.CAP/IQueueExecutor.Publish.Base.cs index 09f7d40..074fd66 100644 --- a/src/DotNetCore.CAP/IQueueExecutor.Publish.Base.cs +++ b/src/DotNetCore.CAP/IQueueExecutor.Publish.Base.cs @@ -1,11 +1,9 @@ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Text; using System.Threading.Tasks; +using DotNetCore.CAP.Models; using DotNetCore.CAP.Processor; using DotNetCore.CAP.Processor.States; -using DotNetCore.CAP.Models; using Microsoft.Extensions.Logging; namespace DotNetCore.CAP @@ -28,8 +26,7 @@ namespace DotNetCore.CAP { using (fetched) { - - var message = await connection.GetSentMessageAsync(fetched.MessageId); + var message = await connection.GetPublishedMessageAsync(fetched.MessageId); try { var sp = Stopwatch.StartNew(); @@ -39,7 +36,7 @@ namespace DotNetCore.CAP { _logger.JobRetrying(message.Retries); } - var result = await PublishAsync(message.KeyName, message.Content); + var result = await PublishAsync(message.Name, message.Content); sp.Stop(); var newState = default(IState); @@ -72,16 +69,15 @@ namespace DotNetCore.CAP return OperateResult.Success; } - catch (Exception ex) { - _logger.ExceptionOccuredWhileExecutingJob(message?.KeyName, ex); + _logger.ExceptionOccuredWhileExecutingJob(message?.Name, ex); return OperateResult.Failed(ex); } } } - private async Task UpdateJobForRetryAsync(CapSentMessage message, IStorageConnection connection) + private async Task UpdateJobForRetryAsync(CapPublishedMessage message, IStorageConnection connection) { var retryBehavior = RetryBehavior.DefaultRetry; @@ -102,4 +98,4 @@ namespace DotNetCore.CAP return true; } } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/IStorageConnection.cs b/src/DotNetCore.CAP/IStorageConnection.cs index da3b799..4c16a5f 100644 --- a/src/DotNetCore.CAP/IStorageConnection.cs +++ b/src/DotNetCore.CAP/IStorageConnection.cs @@ -9,14 +9,13 @@ namespace DotNetCore.CAP /// public interface IStorageConnection : IDisposable { - - //Sent messages + //Sent messages /// /// Returns the message with the given id. /// /// The message's id. - Task GetSentMessageAsync(string id); + Task GetPublishedMessageAsync(int id); /// /// Fetches the next message to be executed. @@ -26,7 +25,7 @@ namespace DotNetCore.CAP /// /// Returns the next message to be enqueued. /// - Task GetNextSentMessageToBeEnqueuedAsync(); + Task GetNextPublishedMessageToBeEnqueuedAsync(); // Received messages @@ -40,14 +39,13 @@ namespace DotNetCore.CAP /// Returns the message with the given id. /// /// The message's id. - Task GetReceivedMessageAsync(string id); - + Task GetReceivedMessageAsync(int id); /// /// Returns the next message to be enqueued. /// Task GetNextReceviedMessageToBeEnqueuedAsync(); - + //----------------------------------------- /// @@ -55,4 +53,4 @@ namespace DotNetCore.CAP /// IStorageTransaction CreateTransaction(); } -} +} \ No newline at end of file diff --git a/src/DotNetCore.CAP/IStorageTransaction.cs b/src/DotNetCore.CAP/IStorageTransaction.cs index 7aaf6e1..642cc4d 100644 --- a/src/DotNetCore.CAP/IStorageTransaction.cs +++ b/src/DotNetCore.CAP/IStorageTransaction.cs @@ -6,11 +6,11 @@ namespace DotNetCore.CAP { public interface IStorageTransaction : IDisposable { - void UpdateMessage(CapSentMessage message); + void UpdateMessage(CapPublishedMessage message); void UpdateMessage(CapReceivedMessage message); - void EnqueueMessage(CapSentMessage message); + void EnqueueMessage(CapPublishedMessage message); void EnqueueMessage(CapReceivedMessage message); diff --git a/src/DotNetCore.CAP/Models/CapSentMessage.cs b/src/DotNetCore.CAP/Models/CapPublishedMessage.cs similarity index 63% rename from src/DotNetCore.CAP/Models/CapSentMessage.cs rename to src/DotNetCore.CAP/Models/CapPublishedMessage.cs index 6752536..7780a09 100644 --- a/src/DotNetCore.CAP/Models/CapSentMessage.cs +++ b/src/DotNetCore.CAP/Models/CapPublishedMessage.cs @@ -3,29 +3,28 @@ using DotNetCore.CAP.Infrastructure; namespace DotNetCore.CAP.Models { - public class CapSentMessage + public class CapPublishedMessage { /// - /// Initializes a new instance of . + /// Initializes a new instance of . /// /// /// The Id property is initialized to from a new GUID string value. /// - public CapSentMessage() + public CapPublishedMessage() { - Id = Guid.NewGuid().ToString(); Added = DateTime.Now; } - public CapSentMessage(MessageContext message) + public CapPublishedMessage(MessageContext message) { - KeyName = message.KeyName; + Name = message.Name; Content = message.Content; } - public string Id { get; set; } + public int Id { get; set; } - public string KeyName { get; set; } + public string Name { get; set; } public string Content { get; set; } diff --git a/src/DotNetCore.CAP/Processor/States/IState.Enqueued.cs b/src/DotNetCore.CAP/Processor/States/IState.Enqueued.cs index 41d83ae..ca53699 100644 --- a/src/DotNetCore.CAP/Processor/States/IState.Enqueued.cs +++ b/src/DotNetCore.CAP/Processor/States/IState.Enqueued.cs @@ -11,7 +11,7 @@ namespace DotNetCore.CAP.Processor.States public string Name => StateName; - public void Apply(CapSentMessage message, IStorageTransaction transaction) + public void Apply(CapPublishedMessage message, IStorageTransaction transaction) { transaction.EnqueueMessage(message); } diff --git a/src/DotNetCore.CAP/Processor/States/IState.Failed.cs b/src/DotNetCore.CAP/Processor/States/IState.Failed.cs index 9bbfbd6..49fda9b 100644 --- a/src/DotNetCore.CAP/Processor/States/IState.Failed.cs +++ b/src/DotNetCore.CAP/Processor/States/IState.Failed.cs @@ -11,7 +11,7 @@ namespace DotNetCore.CAP.Processor.States public string Name => StateName; - public void Apply(CapSentMessage message, IStorageTransaction transaction) + public void Apply(CapPublishedMessage message, IStorageTransaction transaction) { } diff --git a/src/DotNetCore.CAP/Processor/States/IState.Processing.cs b/src/DotNetCore.CAP/Processor/States/IState.Processing.cs index db66b86..9827e76 100644 --- a/src/DotNetCore.CAP/Processor/States/IState.Processing.cs +++ b/src/DotNetCore.CAP/Processor/States/IState.Processing.cs @@ -11,7 +11,7 @@ namespace DotNetCore.CAP.Processor.States public string Name => StateName; - public void Apply(CapSentMessage message, IStorageTransaction transaction) + public void Apply(CapPublishedMessage message, IStorageTransaction transaction) { } diff --git a/src/DotNetCore.CAP/Processor/States/IState.Scheduled.cs b/src/DotNetCore.CAP/Processor/States/IState.Scheduled.cs index 6113f3b..49f0c95 100644 --- a/src/DotNetCore.CAP/Processor/States/IState.Scheduled.cs +++ b/src/DotNetCore.CAP/Processor/States/IState.Scheduled.cs @@ -11,7 +11,7 @@ namespace DotNetCore.CAP.Processor.States public string Name => StateName; - public void Apply(CapSentMessage message, IStorageTransaction transaction) + public void Apply(CapPublishedMessage message, IStorageTransaction transaction) { } diff --git a/src/DotNetCore.CAP/Processor/States/IState.Succeeded.cs b/src/DotNetCore.CAP/Processor/States/IState.Succeeded.cs index b3b4f4d..294591c 100644 --- a/src/DotNetCore.CAP/Processor/States/IState.Succeeded.cs +++ b/src/DotNetCore.CAP/Processor/States/IState.Succeeded.cs @@ -11,7 +11,7 @@ namespace DotNetCore.CAP.Processor.States public string Name => StateName; - public void Apply(CapSentMessage message, IStorageTransaction transaction) + public void Apply(CapPublishedMessage message, IStorageTransaction transaction) { } diff --git a/src/DotNetCore.CAP/Processor/States/IState.cs b/src/DotNetCore.CAP/Processor/States/IState.cs index 0416fe9..c43fc74 100644 --- a/src/DotNetCore.CAP/Processor/States/IState.cs +++ b/src/DotNetCore.CAP/Processor/States/IState.cs @@ -9,7 +9,7 @@ namespace DotNetCore.CAP.Processor.States string Name { get; } - void Apply(CapSentMessage message, IStorageTransaction transaction); + void Apply(CapPublishedMessage message, IStorageTransaction transaction); void Apply(CapReceivedMessage message, IStorageTransaction transaction); } diff --git a/src/DotNetCore.CAP/Processor/States/IStateChanger.Default.cs b/src/DotNetCore.CAP/Processor/States/IStateChanger.Default.cs index 1e4c99b..b8b419b 100644 --- a/src/DotNetCore.CAP/Processor/States/IStateChanger.Default.cs +++ b/src/DotNetCore.CAP/Processor/States/IStateChanger.Default.cs @@ -4,7 +4,7 @@ namespace DotNetCore.CAP.Processor.States { public class StateChanger : IStateChanger { - public void ChangeState(CapSentMessage message, IState state, IStorageTransaction transaction) + public void ChangeState(CapPublishedMessage message, IState state, IStorageTransaction transaction) { //var now = DateTime.UtcNow; //if (state.ExpiresAfter != null) diff --git a/src/DotNetCore.CAP/Processor/States/IStateChanger.Extensions.cs b/src/DotNetCore.CAP/Processor/States/IStateChanger.Extensions.cs index 5ccc018..6bd1d12 100644 --- a/src/DotNetCore.CAP/Processor/States/IStateChanger.Extensions.cs +++ b/src/DotNetCore.CAP/Processor/States/IStateChanger.Extensions.cs @@ -6,7 +6,7 @@ namespace DotNetCore.CAP.Processor.States public static class StateChangerExtensions { public static async Task ChangeStateAsync( - this IStateChanger @this, CapSentMessage message, IState state, IStorageConnection connection) + this IStateChanger @this, CapPublishedMessage message, IState state, IStorageConnection connection) { using (var transaction = connection.CreateTransaction()) { diff --git a/src/DotNetCore.CAP/Processor/States/IStateChanger.cs b/src/DotNetCore.CAP/Processor/States/IStateChanger.cs index 1cba968..949ea31 100644 --- a/src/DotNetCore.CAP/Processor/States/IStateChanger.cs +++ b/src/DotNetCore.CAP/Processor/States/IStateChanger.cs @@ -4,7 +4,7 @@ namespace DotNetCore.CAP.Processor.States { public interface IStateChanger { - void ChangeState(CapSentMessage message, IState state, IStorageTransaction transaction); + void ChangeState(CapPublishedMessage message, IState state, IStorageTransaction transaction); void ChangeState(CapReceivedMessage message, IState state, IStorageTransaction transaction); }