wanshenmean
3 天以前 5e851678cc02257bbbd179446de36082430ca5bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
namespace WIDESEAWCS_RedisService.Stream
{
    public interface IStreamProcessingService
    {
        /// <summary>
        /// 发送消息到Stream
        /// </summary>
        string AddMessage(string streamKey, Dictionary<string, string> fields);
 
        /// <summary>
        /// 创建消费者组
        /// </summary>
        bool CreateConsumerGroup(string streamKey, string groupName, string startId = "$");
 
        /// <summary>
        /// 读取消息(消费者组模式)
        /// </summary>
        List<StreamEntry> ReadGroup(string streamKey, string groupName, string consumerName, int count = 10);
 
        /// <summary>
        /// 确认消息
        /// </summary>
        long Acknowledge(string streamKey, string groupName, params string[] messageIds);
 
        /// <summary>
        /// 获取Stream长度
        /// </summary>
        long GetStreamLength(string streamKey);
 
        /// <summary>
        /// 裁剪Stream
        /// </summary>
        long TrimStream(string streamKey, int maxLength);
    }
 
    public class StreamEntry
    {
        public string Id { get; set; } = string.Empty;
        public Dictionary<string, string> Fields { get; set; } = new();
    }
}