예제 #1
0
            public ProducerResponse ParseFrom(KafkaBinaryReader reader)
            {
                var size          = reader.ReadInt32();
                var correlationId = reader.ReadInt32();
                var topicCount    = reader.ReadInt32();

                var statuses = new Dictionary <TopicAndPartition, ProducerResponseStatus>();

                for (var i = 0; i < topicCount; ++i)
                {
                    var topic          = reader.ReadShortString();
                    var partitionCount = reader.ReadInt32();
                    for (var p = 0; p < partitionCount; ++p)
                    {
                        var partitionId       = reader.ReadInt32();
                        var error             = reader.ReadInt16();
                        var offset            = reader.ReadInt64();
                        var topicAndPartition = new TopicAndPartition(topic, partitionId);

                        statuses.Add(topicAndPartition, new ProducerResponseStatus
                        {
                            Error  = ErrorMapper.ToError(error),
                            Offset = offset
                        });
                    }
                }

                return(new ProducerResponse(correlationId, statuses));
            }
        public void TopicAndPartitionShouldEqual()
        {
            var tp = new TopicAndPartition("testTopic", 1);
            var tp2 = new TopicAndPartition("testTopic", 1);

            tp.Equals(tp2).Should().BeTrue();
            tp.Equals(new TopicAndPartition("testTopic2", 1)).Should().BeFalse();
        }
 public void ShouldHoldTopicAndPartition()
 {
     var tp = new TopicAndPartition("testTopic", 1);
     tp.PartitionId.Should().Be(1);
     tp.Topic.Should().Be("testTopic");
 }