예제 #1
0
        public IEnumerable <OffsetFetchResponse> Decode(byte[] data)
        {
            var stream        = new BinaryReader(data);
            var correlationId = stream.ReadInt32();

            var topicCount = stream.ReadInt32();

            for (int i = 0; i < topicCount; i++)
            {
                var topic = stream.ReadInt16String();

                var partitionCount = stream.ReadInt32();
                for (int j = 0; j < partitionCount; j++)
                {
                    var response = new OffsetFetchResponse()
                    {
                        Topic       = topic,
                        PartitionId = stream.ReadInt32(),
                        Offset      = stream.ReadInt64(),
                        MetaData    = stream.ReadInt16String(),
                        Error       = stream.ReadInt16()
                    };

                    yield return(response);
                }
            }
        }
예제 #2
0
        public IEnumerable <OffsetResponse> Decode(byte[] data)
        {
            var stream = new BinaryReader(data);

            var correlationId = stream.ReadInt32();

            var topicCount = stream.ReadInt32();

            for (int i = 0; i < topicCount; i++)
            {
                var topic = stream.ReadInt16String();

                var partitionCount = stream.ReadInt32();
                for (int j = 0; j < partitionCount; j++)
                {
                    var response = new OffsetResponse()
                    {
                        Topic       = topic,
                        PartitionId = stream.ReadInt32(),
                        Error       = stream.ReadInt16(),
                        Offsets     = new List <long>()
                    };
                    var offsetCount = stream.ReadInt32();
                    for (int k = 0; k < offsetCount; k++)
                    {
                        response.Offsets.Add(stream.ReadInt64());
                    }

                    yield return(response);
                }
            }
        }
예제 #3
0
        public IEnumerable <FetchResponse> Decode(byte[] data)
        {
            var stream = new BinaryReader(data);

            var correlationId = stream.ReadInt32();
            var topicCount    = stream.ReadInt32();

            for (int i = 0; i < topicCount; i++)
            {
                var topic = stream.ReadInt16String();

                var partitionCount = stream.ReadInt32();
                for (int j = 0; j < partitionCount; j++)
                {
                    var partitionId = stream.ReadInt32();
                    var response    = new FetchResponse
                    {
                        Topic         = topic,
                        PartitionId   = partitionId,
                        Error         = stream.ReadInt16(),
                        HighWaterMark = stream.ReadInt64()
                    };

                    // The length of the message payload
                    var length = stream.ReadInt32();
                    response.Messages = Message.DecodeMessages(data, stream.Position, length, partitionId)
                                        .ToList();
                    stream.Position += length;
                    yield return(response);
                }
            }
        }
예제 #4
0
 public static Broker FromStream(BinaryReader reader)
 {
     return new Broker
         {
             BrokerId = reader.ReadInt32(),
             Host = reader.ReadInt16String(),
             Port = reader.ReadInt32()
         };
 }
예제 #5
0
 public static Broker FromStream(BinaryReader reader)
 {
     return(new Broker
     {
         BrokerId = reader.ReadInt32(),
         Host = reader.ReadInt16String(),
         Port = reader.ReadInt32()
     });
 }
예제 #6
0
        public IEnumerable <ConsumerMetadataResponse> Decode(byte[] payload)
        {
            var stream = new BinaryReader(payload);

            var correlationId = stream.ReadInt32();

            var response = new ConsumerMetadataResponse
            {
                Error           = stream.ReadInt16(),
                CoordinatorId   = stream.ReadInt32(),
                CoordinatorHost = stream.ReadInt16String(),
                CoordinatorPort = stream.ReadInt32()
            };

            yield return(response);
        }
예제 #7
0
        public static Topic FromStream(BinaryReader stream)
        {
            var topic = new Topic
                {
                    ErrorCode = stream.ReadInt16(),
                    Name = stream.ReadInt16String(),
                    Partitions = new List<Partition>()
                };

            var numPartitions = stream.ReadInt32();
            for (int i = 0; i < numPartitions; i++)
            {
                topic.Partitions.Add(Partition.FromStream(stream));
            }

            return topic;
        }
예제 #8
0
        public static Topic FromStream(BinaryReader stream)
        {
            var topic = new Topic
            {
                ErrorCode  = stream.ReadInt16(),
                Name       = stream.ReadInt16String(),
                Partitions = new List <Partition>()
            };

            var numPartitions = stream.ReadInt32();

            for (int i = 0; i < numPartitions; i++)
            {
                topic.Partitions.Add(Partition.FromStream(stream));
            }

            return(topic);
        }