Exemplo n.º 1
0
        private static byte[] EncodeRequest(IRequestContext context, OffsetRequest request)
        {
            using (var writer = EncodeHeader(context, request)) {
                var topicGroups = request.Topics.GroupBy(x => x.TopicName).ToList();
                writer.Write(ReplicaId)
                .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(partition.Key)
                            .Write(offset.Timestamp);

                            if (context.ApiVersion == 0)
                            {
                                writer.Write(offset.MaxOffsets);
                            }
                        }
                    }
                }

                return(writer.ToBytes());
            }
        }
Exemplo n.º 2
0
 /// <inheritdoc />
 public bool Equals(OffsetRequest other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Topics.HasEqualElementsInOrder(other.Topics));
 }