31 lines
767 B
C#
31 lines
767 B
C#
using Confluent.Kafka;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace JiShe.CollectBus.Kafka
|
|
{
|
|
/// <summary>
|
|
/// 消息头过滤器
|
|
/// </summary>
|
|
public class HeadersFilter : Dictionary<string, byte[]>
|
|
{
|
|
/// <summary>
|
|
/// 判断Headers是否匹配
|
|
/// </summary>
|
|
/// <param name="headers"></param>
|
|
/// <returns></returns>
|
|
public bool Match(Headers headers)
|
|
{
|
|
foreach (var kvp in this)
|
|
{
|
|
if (!headers.TryGetLastBytes(kvp.Key, out var value) || !value.SequenceEqual(kvp.Value))
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|