コード例 #1
0
        protected IEnumerable <OffsetFetchResponse> DecodeOffsetFetchResponse(byte[] data)
        {
            var stream        = new ReadByteStream(data);
            var correlationId = stream.ReadInt();

            var topicCount = stream.ReadInt();

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

                var partitionCount = stream.ReadInt();
                for (int j = 0; j < partitionCount; j++)
                {
                    var response = new OffsetFetchResponse()
                    {
                        Topic       = topic,
                        PartitionId = stream.ReadInt(),
                        Offset      = stream.ReadLong(),
                        MetaData    = stream.ReadInt16String(),
                        Error       = stream.ReadInt16()
                    };
                    yield return(response);
                }
            }
        }
コード例 #2
0
ファイル: OffsetRequest.cs プロジェクト: nberglund/kafka-net
        private IEnumerable <OffsetResponse> DecodeOffsetResponse(byte[] data)
        {
            var stream = new ReadByteStream(data);

            var correlationId = stream.ReadInt();

            var topicCount = stream.ReadInt();

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

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

                    yield return(response);
                }
            }
        }
コード例 #3
0
ファイル: FetchRequest.cs プロジェクト: jmucza/kafka-net
        private IEnumerable <FetchResponse> DecodeFetchResponse(byte[] data)
        {
            var stream = new ReadByteStream(data);

            var correlationId = stream.ReadInt();

            var topicCount = stream.ReadInt();

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

                var partitionCount = stream.ReadInt();
                for (int j = 0; j < partitionCount; j++)
                {
                    var partitionId = stream.ReadInt();
                    var response    = new FetchResponse
                    {
                        Topic         = topic,
                        PartitionId   = partitionId,
                        Error         = stream.ReadInt16(),
                        HighWaterMark = stream.ReadLong()
                    };
                    //note: dont use initializer here as it breaks stream position.
                    response.Messages = Message.DecodeMessageSet(stream.ReadIntPrefixedBytes())
                                        .Select(x => { x.Meta.PartitionId = partitionId; return(x); });

                    yield return(response);
                }
            }
        }
コード例 #4
0
ファイル: Broker.cs プロジェクト: ranjancse26/kafka-net
 public static Broker FromStream(ReadByteStream stream)
 {
     return(new Broker
     {
         BrokerId = stream.ReadInt(),
         Host = stream.ReadInt16String(),
         Port = stream.ReadInt()
     });
 }
コード例 #5
0
        private IEnumerable <ConsumerMetadataResponse> DecodeConsumerMetadataResponse(byte[] data)
        {
            var stream = new ReadByteStream(data);

            var correlationId = stream.ReadInt();

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

            yield return(response);
        }
コード例 #6
0
        public static Topic FromStream(ReadByteStream stream)
        {
            var topic = new Topic
            {
                ErrorCode  = stream.ReadInt16(),
                Name       = stream.ReadInt16String(),
                Partitions = new List <Partition>()
            };

            var numPartitions = stream.ReadInt();

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

            return(topic);
        }