Merge branch 'master' into lida_Dev

This commit is contained in:
AnonymousDotNet 2024-11-26 18:26:10 +08:00
commit b4e0f1d997
3 changed files with 7 additions and 3 deletions

View file

@ -10,7 +10,7 @@ public interface IEventPublisher
/// <returns></returns> /// <returns></returns>
Task BroadcastAsync(string channel, string message); Task BroadcastAsync(string channel, string message);
Task PublishAsync(string channel, string message, EventPriority? priority = null); Task<string?> PublishAsync(string channel, string message, EventPriority? priority = null);
Task ReDispatchAsync(string channel, int count = 10, string order = "asc"); Task ReDispatchAsync(string channel, int count = 10, string order = "asc");

View file

@ -1,7 +1,9 @@
using BotSharp.Abstraction.Infrastructures; using BotSharp.Abstraction.Infrastructures;
using System.Diagnostics;
namespace BotSharp.Abstraction.Utilities; namespace BotSharp.Abstraction.Utilities;
[DebuggerStepThrough]
public class Pagination : ICacheKey public class Pagination : ICacheKey
{ {
private int _page; private int _page;

View file

@ -21,7 +21,7 @@ public class RedisPublisher : IEventPublisher
await _subscriber.PublishAsync(channel, message); await _subscriber.PublishAsync(channel, message);
} }
public async Task PublishAsync(string channel, string message, EventPriority? priority = null) public async Task<string?> PublishAsync(string channel, string message, EventPriority? priority = null)
{ {
var db = _redis.GetDatabase(); var db = _redis.GetDatabase();
@ -34,7 +34,7 @@ public class RedisPublisher : IEventPublisher
if (CheckMessageExists(db, channel, "message", message)) if (CheckMessageExists(db, channel, "message", message))
{ {
_logger.LogError($"The message already exists {channel} {message}"); _logger.LogError($"The message already exists {channel} {message}");
return; return null;
} }
// Add a message to the stream, keeping only the latest 1 million messages // Add a message to the stream, keeping only the latest 1 million messages
@ -46,6 +46,8 @@ public class RedisPublisher : IEventPublisher
maxLength: 1000 * 10000); maxLength: 1000 * 10000);
_logger.LogInformation($"Published message {channel} {message} ({messageId})"); _logger.LogInformation($"Published message {channel} {message} ({messageId})");
return messageId;
} }
private bool CheckMessageExists(IDatabase db, string channel, string fieldName, string desiredValue) private bool CheckMessageExists(IDatabase db, string channel, string fieldName, string desiredValue)