예제 #1
0
        private static byte[] EncodeRequest(IRequestContext context, OffsetFetchRequest request)
        {
            using (var writer = EncodeHeader(context, request)) {
                var topicGroups = request.Topics.GroupBy(x => x.TopicName).ToList();

                writer.Write(request.GroupId)
                .Write(topicGroups.Count);

                foreach (var topicGroup in topicGroups)
                {
                    var partitions = topicGroup.GroupBy(x => x.PartitionId).ToList();
                    writer.Write(topicGroup.Key)
                    .Write(partitions.Count);

                    foreach (var partition in partitions)
                    {
                        foreach (var offset in partition)
                        {
                            writer.Write(offset.PartitionId);
                        }
                    }
                }

                return(writer.ToBytes());
            }
        }
예제 #2
0
 /// <inheritdoc />
 public bool Equals(OffsetFetchRequest other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(string.Equals(GroupId, other.GroupId) &&
            Topics.HasEqualElementsInOrder(other.Topics));
 }