Commit a060be4f authored by yangxiaodong's avatar yangxiaodong

refactor

parent c364e476
using System;
namespace Cap.Consistency.Infrastructure
{
/// <summary>
/// The default implementation of <see cref="ConsistencyMessage{TKey}"/> which uses a string as a primary key.
/// </summary>
public class ConsistencyMessage : ConsistencyMessage<string>
{
/// <summary>
/// Initializes a new instance of <see cref="ConsistencyMessage"/>.
/// </summary>
/// <remarks>
/// The Id property is initialized to from a new GUID string value.
/// </remarks>
public ConsistencyMessage() {
Id = Guid.NewGuid().ToString();
SendTime = DateTime.Now;
UpdateTime = SendTime;
Status = MessageStatus.WaitForSend;
}
}
/// <summary>
/// ConsistencyMessage consume status
/// </summary>
public enum MessageStatus
{
Deleted = 0,
WaitForSend = 1,
RollbackSuccessed = 3,
RollbackFailed = 4
}
/// <summary>
/// Represents a message in the consistency system
/// </summary>
/// <typeparam name="TKey">The type used for the primary key for the message.</typeparam>
public class ConsistencyMessage<TKey> where TKey : IEquatable<TKey>
{
public virtual TKey Id { get; set; }
public virtual DateTime SendTime { get; set; }
public string Payload { get; set; }
public MessageStatus Status { get; set; }
public virtual DateTime? UpdateTime { get; set; }
}
}
\ No newline at end of file
...@@ -16,6 +16,8 @@ namespace Cap.Consistency.Infrastructure ...@@ -16,6 +16,8 @@ namespace Cap.Consistency.Infrastructure
public byte[] Body { get; set; } public byte[] Body { get; set; }
public string Value { get; set; }
} }
...@@ -27,6 +29,5 @@ namespace Cap.Consistency.Infrastructure ...@@ -27,6 +29,5 @@ namespace Cap.Consistency.Infrastructure
public long Offset { get; set; } public long Offset { get; set; }
public string MessageId { get; set; } public string MessageId { get; set; }
} }
} }
...@@ -10,6 +10,6 @@ namespace Cap.Consistency.Infrastructure ...@@ -10,6 +10,6 @@ namespace Cap.Consistency.Infrastructure
{ {
IReadOnlyList<ConsumerExecutorDescriptor> SelectCandidates(TopicRouteContext context); IReadOnlyList<ConsumerExecutorDescriptor> SelectCandidates(TopicRouteContext context);
ConsumerExecutorDescriptor SelectBestCandidate(TopicRouteContext context, IReadOnlyList<ConsumerExecutorDescriptor> executeDescriptor); ConsumerExecutorDescriptor SelectBestCandidate(string key, IReadOnlyList<ConsumerExecutorDescriptor> executeDescriptor);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment