Browse Source

code cleanup

master
Savorboard 5 years ago
parent
commit
e5175a6ceb
18 changed files with 19 additions and 224 deletions
  1. +1
    -1
      src/DotNetCore.CAP.MySql/MySqlDataStorage.cs
  2. +1
    -1
      src/DotNetCore.CAP/Abstractions/CapPublisher.cs
  3. +10
    -3
      src/DotNetCore.CAP/CAP.Attribute.cs
  4. +0
    -13
      src/DotNetCore.CAP/Cap.Header.cs
  5. +0
    -19
      src/DotNetCore.CAP/ICallbackPublisher.cs
  6. +1
    -1
      src/DotNetCore.CAP/IConsumerServiceSelector.Default.cs
  7. +0
    -62
      src/DotNetCore.CAP/IStorageConnection.cs
  8. +0
    -1
      src/DotNetCore.CAP/ISubscribeExecutor.Default.cs
  9. +1
    -1
      src/DotNetCore.CAP/Internal/Helper.cs
  10. +0
    -1
      src/DotNetCore.CAP/Internal/IMessageSender.Default.cs
  11. +1
    -1
      src/DotNetCore.CAP/Internal/ObjectId.cs
  12. +1
    -1
      src/DotNetCore.CAP/Internal/SnowflakeId.cs
  13. +1
    -1
      src/DotNetCore.CAP/Internal/StatusName.cs
  14. +1
    -1
      src/DotNetCore.CAP/Internal/WaitHandleEx.cs
  15. +0
    -25
      src/DotNetCore.CAP/Persistence/CapPublishedMessage.cs
  16. +0
    -39
      src/DotNetCore.CAP/Persistence/CapReceivedMessage.cs
  17. +0
    -26
      src/DotNetCore.CAP/Persistence/IDashboardQuerying.cs
  18. +1
    -27
      src/DotNetCore.CAP/Persistence/IDataStorage.cs

+ 1
- 1
src/DotNetCore.CAP.MySql/MySqlDataStorage.cs View File

@@ -4,7 +4,7 @@ using System.Data;
using System.Threading;
using System.Threading.Tasks;
using Dapper;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Internal;
using DotNetCore.CAP.Messages;
using DotNetCore.CAP.Persistence;
using DotNetCore.CAP.Serialization;


+ 1
- 1
src/DotNetCore.CAP/Abstractions/CapPublisher.cs View File

@@ -7,7 +7,7 @@ using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using DotNetCore.CAP.Diagnostics;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Internal;
using DotNetCore.CAP.Messages;
using DotNetCore.CAP.Persistence;
using Microsoft.Extensions.DependencyInjection;


src/DotNetCore.CAP/CAP.SubscribeAttribute.cs → src/DotNetCore.CAP/CAP.Attribute.cs View File

@@ -2,14 +2,13 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using DotNetCore.CAP.Abstractions;

// ReSharper disable once CheckNamespace
namespace DotNetCore.CAP
{
/// <summary>
/// An attribute for subscribe event bus message.
/// </summary>
public class CapSubscribeAttribute : TopicAttribute
{
public CapSubscribeAttribute(string name)
@@ -29,4 +28,12 @@ namespace DotNetCore.CAP
{
}

public class CapHeader : ReadOnlyDictionary<string, string>
{
public CapHeader(IDictionary<string, string> dictionary) : base(dictionary)
{

}
}
}

+ 0
- 13
src/DotNetCore.CAP/Cap.Header.cs View File

@@ -1,13 +0,0 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace DotNetCore.CAP
{
public class CapHeader : ReadOnlyDictionary<string, string>
{
public CapHeader(IDictionary<string, string> dictionary) : base(dictionary)
{

}
}
}

+ 0
- 19
src/DotNetCore.CAP/ICallbackPublisher.cs View File

@@ -1,19 +0,0 @@
// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Threading.Tasks;
using DotNetCore.CAP.Messages;

namespace DotNetCore.CAP
{
/// <summary>
/// A callback that is sent to Producer after a successful consumer execution
/// </summary>
public interface ICallbackPublisher
{
/// <summary>
/// Publish a callback message
/// </summary>
Task PublishCallbackAsync(CapPublishedMessage obj);
}
}

+ 1
- 1
src/DotNetCore.CAP/IConsumerServiceSelector.Default.cs View File

@@ -7,9 +7,9 @@ using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using DotNetCore.CAP.Abstractions;
using DotNetCore.CAP.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
using System.Collections.Concurrent;
using DotNetCore.CAP.Internal;
using Microsoft.Extensions.Options;
namespace DotNetCore.CAP


+ 0
- 62
src/DotNetCore.CAP/IStorageConnection.cs View File

@@ -1,62 +0,0 @@
// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Threading.Tasks;
using DotNetCore.CAP.Messages;

namespace DotNetCore.CAP
{
/// <summary>
/// Represents a connection to the storage.
/// </summary>
public interface IStorageConnection
{
//Sent messages

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

/// <summary>
/// Returns executed failed messages.
/// </summary>
Task<IEnumerable<CapPublishedMessage>> GetPublishedMessagesOfNeedRetry();

// Received messages

/// <summary>
/// Stores the message.
/// </summary>
/// <param name="message">The message to store.</param>
void StoreReceivedMessage(CapReceivedMessage message);

/// <summary>
/// Returns the message with the given id.
/// </summary>
/// <param name="id">The message's id.</param>
Task<CapReceivedMessage> GetReceivedMessageAsync(long id);

/// <summary>
/// Returns executed failed message.
/// </summary>
Task<IEnumerable<CapReceivedMessage>> GetReceivedMessagesOfNeedRetry();


/// <summary>
/// Change specified message's state of published message
/// </summary>
/// <param name="messageId">Message id</param>
/// <param name="state">State name</param>
bool ChangePublishedState(long messageId, string state);

/// <summary>
/// Change specified message's state of received message
/// </summary>
/// <param name="messageId">Message id</param>
/// <param name="state">State name</param>
bool ChangeReceivedState(long messageId, string state);
}
}

+ 0
- 1
src/DotNetCore.CAP/ISubscribeExecutor.Default.cs View File

@@ -7,7 +7,6 @@ using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using DotNetCore.CAP.Diagnostics;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Internal;
using DotNetCore.CAP.Messages;
using DotNetCore.CAP.Persistence;


src/DotNetCore.CAP/Infrastructure/Helper.cs → src/DotNetCore.CAP/Internal/Helper.cs View File

@@ -5,7 +5,7 @@ using System;
using System.ComponentModel;
using System.Reflection;

namespace DotNetCore.CAP.Infrastructure
namespace DotNetCore.CAP.Internal
{
public static class Helper
{

+ 0
- 1
src/DotNetCore.CAP/Internal/IMessageSender.Default.cs View File

@@ -5,7 +5,6 @@ using System;
using System.Diagnostics;
using System.Threading.Tasks;
using DotNetCore.CAP.Diagnostics;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Messages;
using DotNetCore.CAP.Persistence;
using DotNetCore.CAP.Processor;


src/DotNetCore.CAP/Infrastructure/ObjectId.cs → src/DotNetCore.CAP/Internal/ObjectId.cs View File

@@ -9,7 +9,7 @@ using System.Security.Cryptography;
using System.Text;
using System.Threading;

namespace DotNetCore.CAP.Infrastructure
namespace DotNetCore.CAP.Internal
{
/// <summary>
/// Represents an ObjectId

src/DotNetCore.CAP/Infrastructure/SnowflakeId.cs → src/DotNetCore.CAP/Internal/SnowflakeId.cs View File

@@ -3,7 +3,7 @@

using System;

namespace DotNetCore.CAP.Infrastructure
namespace DotNetCore.CAP.Internal
{
public class SnowflakeId
{

src/DotNetCore.CAP/Infrastructure/StatusName.cs → src/DotNetCore.CAP/Internal/StatusName.cs View File

@@ -1,7 +1,7 @@
// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

namespace DotNetCore.CAP.Infrastructure
namespace DotNetCore.CAP.Internal
{
/// <summary>
/// The message status name.

src/DotNetCore.CAP/Infrastructure/WaitHandleEx.cs → src/DotNetCore.CAP/Internal/WaitHandleEx.cs View File

@@ -5,7 +5,7 @@ using System;
using System.Threading;
using System.Threading.Tasks;

namespace DotNetCore.CAP.Infrastructure
namespace DotNetCore.CAP.Internal
{
public static class WaitHandleEx
{

+ 0
- 25
src/DotNetCore.CAP/Persistence/CapPublishedMessage.cs View File

@@ -1,25 +0,0 @@
// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;

namespace DotNetCore.CAP.Messages
{
public class CapPublishedMessage
{
public CapPublishedMessage()
{
Added = DateTime.Now;
}

public Message Message { get; set; }

public DateTime Added { get; set; }

public DateTime? ExpiresAt { get; set; }

public int Retries { get; set; }

public string StatusName { get; set; }
}
}

+ 0
- 39
src/DotNetCore.CAP/Persistence/CapReceivedMessage.cs View File

@@ -1,39 +0,0 @@
// Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;

namespace DotNetCore.CAP.Messages
{
public class CapReceivedMessage
{
/// <summary>
/// Initializes a new instance of <see cref="CapReceivedMessage" />.
/// </summary>
public CapReceivedMessage()
{
Added = DateTime.Now;
}

public long Id { get; set; }

public string Group { get; set; }

public string Name { get; set; }

public string Content { get; set; }

public DateTime Added { get; set; }

public DateTime? ExpiresAt { get; set; }

public int Retries { get; set; }

public string StatusName { get; set; }

public override string ToString()
{
return "name:" + Name + ", group:" + Group + ", content:" + Content;
}
}
}

+ 0
- 26
src/DotNetCore.CAP/Persistence/IDashboardQuerying.cs View File

@@ -1,26 +0,0 @@
//using System;
//using System.Collections.Generic;
//using DotNetCore.CAP.Dashboard.Monitoring;
//using DotNetCore.CAP.Messages;

//namespace DotNetCore.CAP.Persistence
//{
// public interface IDashboardQuerying
// {
// StatisticsDto GetStatistics();

// IList<MessageDto> Messages(MessageQueryDto queryDto);

// int PublishedFailedCount();

// int PublishedSucceededCount();

// int ReceivedFailedCount();

// int ReceivedSucceededCount();

// IDictionary<DateTime, int> HourlySucceededJobs(MessageType type);

// IDictionary<DateTime, int> HourlyFailedJobs(MessageType type);
// }
//}

+ 1
- 27
src/DotNetCore.CAP/Persistence/IDataStorage.cs View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Internal;
using DotNetCore.CAP.Messages;

namespace DotNetCore.CAP.Persistence
@@ -22,31 +22,5 @@ namespace DotNetCore.CAP.Persistence
Task<IEnumerable<MediumMessage>> GetPublishedMessagesOfNeedRetry();

Task<IEnumerable<MediumMessage>> GetReceivedMessagesOfNeedRetry();

//Task<CapPublishedMessage> GetPublishedMessageAsync(long id);
//Task<CapReceivedMessage> GetReceivedMessageAsync(long id);

//public void UpdateMessage(CapPublishedMessage message)
//{
// if (message == null)
// {
// throw new ArgumentNullException(nameof(message));
// }

// var sql =
// $"UPDATE `{_prefix}.published` SET `Retries` = @Retries,`Content`= @Content,`ExpiresAt` = @ExpiresAt,`StatusName`=@StatusName WHERE `Id`=@Id;";
// _dbConnection.Execute(sql, message);
//}

//public void UpdateMessage(CapReceivedMessage message)
//{
// if (message == null)
// {
// throw new ArgumentNullException(nameof(message));
// }

// var sql = $"UPDATE `{_prefix}.received` SET `Retries` = @Retries,`Content`= @Content,`ExpiresAt` = @ExpiresAt,`StatusName`=@StatusName WHERE `Id`=@Id;";
// _dbConnection.Execute(sql, message);
//}
}
}

Loading…
Cancel
Save