Browse Source

rename sentmessage to publishedmessage.

master
Savorboard 7 years ago
parent
commit
8294a58671
13 changed files with 30 additions and 37 deletions
  1. +6
    -10
      src/DotNetCore.CAP/IQueueExecutor.Publish.Base.cs
  2. +6
    -8
      src/DotNetCore.CAP/IStorageConnection.cs
  3. +2
    -2
      src/DotNetCore.CAP/IStorageTransaction.cs
  4. +7
    -8
      src/DotNetCore.CAP/Models/CapPublishedMessage.cs
  5. +1
    -1
      src/DotNetCore.CAP/Processor/States/IState.Enqueued.cs
  6. +1
    -1
      src/DotNetCore.CAP/Processor/States/IState.Failed.cs
  7. +1
    -1
      src/DotNetCore.CAP/Processor/States/IState.Processing.cs
  8. +1
    -1
      src/DotNetCore.CAP/Processor/States/IState.Scheduled.cs
  9. +1
    -1
      src/DotNetCore.CAP/Processor/States/IState.Succeeded.cs
  10. +1
    -1
      src/DotNetCore.CAP/Processor/States/IState.cs
  11. +1
    -1
      src/DotNetCore.CAP/Processor/States/IStateChanger.Default.cs
  12. +1
    -1
      src/DotNetCore.CAP/Processor/States/IStateChanger.Extensions.cs
  13. +1
    -1
      src/DotNetCore.CAP/Processor/States/IStateChanger.cs

+ 6
- 10
src/DotNetCore.CAP/IQueueExecutor.Publish.Base.cs View File

@@ -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<bool> UpdateJobForRetryAsync(CapSentMessage message, IStorageConnection connection)
private async Task<bool> UpdateJobForRetryAsync(CapPublishedMessage message, IStorageConnection connection)
{
var retryBehavior = RetryBehavior.DefaultRetry;

@@ -102,4 +98,4 @@ namespace DotNetCore.CAP
return true;
}
}
}
}

+ 6
- 8
src/DotNetCore.CAP/IStorageConnection.cs View File

@@ -9,14 +9,13 @@ namespace DotNetCore.CAP
/// </summary>
public interface IStorageConnection : IDisposable
{

//Sent messages
//Sent messages

/// <summary>
/// Returns the message with the given id.
/// </summary>
/// <param name="id">The message's id.</param>
Task<CapSentMessage> GetSentMessageAsync(string id);
Task<CapPublishedMessage> GetPublishedMessageAsync(int id);

/// <summary>
/// Fetches the next message to be executed.
@@ -26,7 +25,7 @@ namespace DotNetCore.CAP
/// <summary>
/// Returns the next message to be enqueued.
/// </summary>
Task<CapSentMessage> GetNextSentMessageToBeEnqueuedAsync();
Task<CapPublishedMessage> GetNextPublishedMessageToBeEnqueuedAsync();

// Received messages

@@ -40,14 +39,13 @@ namespace DotNetCore.CAP
/// Returns the message with the given id.
/// </summary>
/// <param name="id">The message's id.</param>
Task<CapReceivedMessage> GetReceivedMessageAsync(string id);

Task<CapReceivedMessage> GetReceivedMessageAsync(int id);

/// <summary>
/// Returns the next message to be enqueued.
/// </summary>
Task<CapReceivedMessage> GetNextReceviedMessageToBeEnqueuedAsync();
//-----------------------------------------

/// <summary>
@@ -55,4 +53,4 @@ namespace DotNetCore.CAP
/// </summary>
IStorageTransaction CreateTransaction();
}
}
}

+ 2
- 2
src/DotNetCore.CAP/IStorageTransaction.cs View File

@@ -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);



src/DotNetCore.CAP/Models/CapSentMessage.cs → src/DotNetCore.CAP/Models/CapPublishedMessage.cs View File

@@ -3,29 +3,28 @@ using DotNetCore.CAP.Infrastructure;

namespace DotNetCore.CAP.Models
{
public class CapSentMessage
public class CapPublishedMessage
{
/// <summary>
/// Initializes a new instance of <see cref="CapSentMessage"/>.
/// Initializes a new instance of <see cref="CapPublishedMessage"/>.
/// </summary>
/// <remarks>
/// The Id property is initialized to from a new GUID string value.
/// </remarks>
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; }


+ 1
- 1
src/DotNetCore.CAP/Processor/States/IState.Enqueued.cs View File

@@ -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);
}


+ 1
- 1
src/DotNetCore.CAP/Processor/States/IState.Failed.cs View File

@@ -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)
{
}



+ 1
- 1
src/DotNetCore.CAP/Processor/States/IState.Processing.cs View File

@@ -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)
{
}



+ 1
- 1
src/DotNetCore.CAP/Processor/States/IState.Scheduled.cs View File

@@ -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)
{
}



+ 1
- 1
src/DotNetCore.CAP/Processor/States/IState.Succeeded.cs View File

@@ -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)
{
}



+ 1
- 1
src/DotNetCore.CAP/Processor/States/IState.cs View File

@@ -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);
}

+ 1
- 1
src/DotNetCore.CAP/Processor/States/IStateChanger.Default.cs View File

@@ -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)


+ 1
- 1
src/DotNetCore.CAP/Processor/States/IStateChanger.Extensions.cs View File

@@ -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())
{


+ 1
- 1
src/DotNetCore.CAP/Processor/States/IStateChanger.cs View File

@@ -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);
}

Loading…
Cancel
Save