Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
client rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
ml054 committed Apr 4, 2014
1 parent ea68028 commit 44d8cf8
Show file tree
Hide file tree
Showing 165 changed files with 2,074 additions and 15,174 deletions.
216 changes: 169 additions & 47 deletions Settings.StyleCop
@@ -1,40 +1,177 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<StyleCopSettings Version="4.3">
<Parsers>
<Parser ParserId="Microsoft.StyleCop.CSharp.CsParser">
<ParserSettings>
<BooleanProperty Name="AnalyzeDesignerFiles">False</BooleanProperty>
</ParserSettings>
</Parser>
</Parsers>
<StyleCopSettings Version="105">
<Analyzers>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.NamingRules">
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="FieldNamesMustNotBeginWithUnderscore">
<Rule Name="ElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="EnumerationItemsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationMustContainValidXml">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustHaveSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementDocumentationMustHaveSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustHaveSummaryText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementDocumentationMustHaveSummaryText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustNotHaveDefaultSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParametersMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustMatchElementParameters">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustDeclareParameterName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="VoidReturnValueMustNotBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParametersMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParametersMustBeDocumentedPartialClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustMatchTypeParameters">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustDeclareParameterName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PropertySummaryDocumentationMustMatchAccessors">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PropertySummaryDocumentationMustOmitSetAccessorWithRestrictedAccess">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustNotBeCopiedAndPasted">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SingleLineCommentsMustNotUseDocumentationStyleSlashes">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustNotBeEmpty">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustContainWhitespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationMustMeetCharacterPercentage">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ConstructorSummaryDocumentationMustBeginWithStandardText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DestructorSummaryDocumentationMustBeginWithStandardText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationHeadersMustNotContainBlankLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="IncludedDocumentationXPathDoesNotExist">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="IncludeNodeDoesNotContainValidFileAndPath">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="InheritDocMustBeUsedWithInheritingClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="FileMustHaveHeader">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
Expand Down Expand Up @@ -65,22 +202,7 @@
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.OrderingRules">
<Rules>
<Rule Name="UsingDirectivesMustBePlacedWithinNamespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="PrefixLocalCallsWithThis">
<Rule Name="FileHeaderFileNameDocumentationMustMatchTypeName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
Expand Down
9 changes: 9 additions & 0 deletions src/Kafka/Kafka.Client/Api/OffsetRequest.cs
@@ -0,0 +1,9 @@
namespace Kafka.Client.Api
{
internal class OffsetRequest
{

public const string LargestTimeString = "largest";
//TODO finish me
}
}
55 changes: 32 additions & 23 deletions src/Kafka/Kafka.Client/Cfg/AsyncProducerConfiguration.cs
Expand Up @@ -18,50 +18,59 @@
namespace Kafka.Client.Cfg
{
using System.Collections.Generic;
using Kafka.Client.Serialization;
using Kafka.Client.Utils;

/// <summary>
/// Configuration used by the asynchronous producer
/// </summary>
public class AsyncProducerConfiguration : SyncProducerConfiguration, IAsyncProducerConfigShared
{

public const int DefaultQueueBufferingMaxMs = 5000;

public const int DefaultQueueBufferingMaxMessages = 10000;

public const int DefaultQueueEnqueueTimeoutMs = -1;

public const int DefaultBatchNumMessages = 200;

public const string DefaultSerializerClass = "Kafka.Client.Serialization.DefaultEncoder";
public const int DefaultQueueTime = 5000;
public const int DefaultQueueSize = 10000;
public const int DefaultBatchSize = 200;
public const int DefaultEnqueueTimeoutMs = 0;

public const string DefaultKeySerializerClass = DefaultSerializerClass;


public AsyncProducerConfiguration()
{
this.QueueBufferingMaxMs = DefaultQueueBufferingMaxMs;
this.QueueBufferingMaxMessages = DefaultQueueBufferingMaxMessages;
this.QueueEnqueueTimeoutMs = DefaultQueueEnqueueTimeoutMs;
this.BatchNumMessages = DefaultBatchNumMessages;
this.SerializerClass = DefaultSerializerClass;
this.QueueTime = DefaultQueueTime;
this.QueueSize = DefaultQueueSize;
this.BatchSize = DefaultBatchSize;
this.EnqueueTimeoutMs = DefaultEnqueueTimeoutMs;
this.KeySerializerClass = DefaultKeySerializerClass;
}

public AsyncProducerConfiguration(ProducerConfiguration config, int id, string host, int port)
: base(config, id, host, port)
public AsyncProducerConfiguration(ProducerConfigurationSection config, string host, int port)
: base(config, host, port)
{
Guard.NotNull(config, "config");
this.SerializerClass = config.SerializerClass;
this.QueueTime = config.QueueTime;
this.QueueSize = config.QueueSize;
this.BatchSize = config.BatchSize;
this.EnqueueTimeoutMs = config.EnqueueTimeoutMs;

this.QueueBufferingMaxMs = config.QueueBufferingMaxMs;
this.QueueBufferingMaxMessages = config.QueueBufferingMaxMessages;
this.QueueEnqueueTimeoutMs = config.QueueEnqueueTimeoutMs;
this.BatchNumMessages = config.BatchNumMessages;
this.SerializerClass = config.Serializer;
this.KeySerializerClass = config.KeySerializer;
}

public string SerializerClass { get; set; }
public int QueueBufferingMaxMs { get; set; }

public string CallbackHandlerClass { get; set; }
public int QueueBufferingMaxMessages { get; set; }

public int QueueTime { get; set; }
public int QueueEnqueueTimeoutMs { get; set; }

public int QueueSize { get; set; }
public int BatchNumMessages { get; set; }

public int BatchSize { get; set; }
public string SerializerClass { get; set; }

public int EnqueueTimeoutMs { get; set; }
public string KeySerializerClass { get; set; }
}
}
6 changes: 3 additions & 3 deletions src/Kafka/Kafka.Client/Cfg/ConsumerConfiguration.cs
Expand Up @@ -16,8 +16,7 @@
*/
namespace Kafka.Client.Cfg
{
using Kafka.Client.Exceptions;
using Kafka.Client.Requests;
using Kafka.Client.Api;
using System.Configuration;
using System.Net;
using System.Globalization;
Expand All @@ -28,6 +27,7 @@ namespace Kafka.Client.Cfg
/// <summary>
/// Configuration used by the consumer
/// </summary>
/// TODO: review and update props
public class ConsumerConfiguration
{
public const short DefaultNumberOfTries = 2;
Expand All @@ -54,7 +54,7 @@ public ConsumerConfiguration()
{
this.NumberOfTries = DefaultNumberOfTries;
this.Timeout = DefaultTimeout;
this.AutoOffsetReset = OffsetRequest.SmallestTime;
//TODO:this.AutoOffsetReset = OffsetRequest.SmallestTime;
this.AutoCommit = DefaultAutoCommit;
this.AutoCommitInterval = DefaultAutoCommitInterval;
this.FetchSize = DefaultFetchSize;
Expand Down
5 changes: 3 additions & 2 deletions src/Kafka/Kafka.Client/Cfg/ConsumerConfigurationSection.cs
Expand Up @@ -17,9 +17,10 @@
namespace Kafka.Client.Cfg
{
using System.Configuration;
using Kafka.Client.Requests;
using System.Xml.Linq;

using Kafka.Client.Api;


public class ConsumerConfigurationSection : ConfigurationSection
{
Expand Down Expand Up @@ -50,7 +51,7 @@ public int Timeout
}
}

[ConfigurationProperty("autoOffsetReset", IsRequired = false, DefaultValue = OffsetRequest.SmallestTime)]
[ConfigurationProperty("autoOffsetReset", IsRequired = false, DefaultValue = OffsetRequest.LargestTimeString)]
public string AutoOffsetReset
{
get
Expand Down
12 changes: 6 additions & 6 deletions src/Kafka/Kafka.Client/Cfg/IAsyncProducerConfigShared.cs
Expand Up @@ -19,16 +19,16 @@ namespace Kafka.Client.Cfg
{
internal interface IAsyncProducerConfigShared
{
string SerializerClass { get; set; }
int QueueBufferingMaxMs { get; set; }

string CallbackHandlerClass { get; set; }
int QueueBufferingMaxMessages { get; set; }

int QueueTime { get; set; }
int QueueEnqueueTimeoutMs { get; set; }

int QueueSize { get; set; }
int BatchNumMessages { get; set; }

int BatchSize { get; set; }
string SerializerClass { get; set; }

int EnqueueTimeoutMs { get; set; }
string KeySerializerClass { get; set; }
}
}

0 comments on commit 44d8cf8

Please sign in to comment.