示例#1
0
        internal static Broker ParseFrom(KafkaBinaryReader reader)
        {
            var id   = reader.ReadInt32();
            var host = BitWorks.ReadShortString(reader, AbstractRequest.DefaultEncoding);
            var port = reader.ReadInt32();

            return(new Broker(id, host, port));
        }
示例#2
0
        public void ShouldReadShortString()
        {
            var stream = new MemoryStream();
            var writer = new KafkaBinaryWriter(stream);

            writer.WriteShortString("hello world");
            stream.Seek(0, SeekOrigin.Begin);
            BitWorks.ReadShortString(new KafkaBinaryReader(stream), "UTF-8").Should().Be("hello world");
        }
示例#3
0
        internal static TopicMetadata ParseFrom(KafkaBinaryReader reader, Dictionary <int, Broker> brokers)
        {
            var errorCode          = reader.ReadInt16();
            var topic              = BitWorks.ReadShortString(reader, AbstractRequest.DefaultEncoding);
            var numPartitions      = reader.ReadInt32();
            var partitionsMetadata = new List <PartitionMetadata>();

            for (var i = 0; i < numPartitions; i++)
            {
                partitionsMetadata.Add(PartitionMetadata.ParseFrom(reader, brokers));
            }
            return(new TopicMetadata(topic, partitionsMetadata, ErrorMapper.ToError(errorCode)));
        }