Skip to content

Commit 4d56f9c

Browse files
lorienpattmhowlett
authored andcommitted
Add a new config GetDouble function. Fix LingerMs (#1083)
* Add a new config GetDouble function. Replace GetEnum function with GetDouble on LingerMs. * fixed whitespace * Adding double as type in ConfigGen project so that Config_Gen can be created correctly * new Config_gen.cs + added LingerMs to test
1 parent cf84fe8 commit 4d56f9c

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

src/ConfigGen/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ static string createProperties(IEnumerable<PropertySpecification> props)
352352
case "bool":
353353
codeText += $"GetBool(\"{prop.Name}\")";
354354
break;
355+
case "double":
356+
codeText += $"GetDouble(\"{prop.Name}\")";
357+
break;
355358
default:
356359
codeText += $"({nullableType})GetEnum(typeof({type}), \"{prop.Name}\")";
357360
break;

src/Confluent.Kafka/Config.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,22 @@ public string Get(string key)
125125
return bool.Parse(result);
126126
}
127127

128+
/// <summary>
129+
/// Gets a configuration property double? value given a key.
130+
/// </summary>
131+
/// <param name="key">
132+
/// The configuration property to get.
133+
/// </param>
134+
/// <returns>
135+
/// The configuration property value.
136+
/// </returns>
137+
protected double? GetDouble(string key)
138+
{
139+
var result = Get(key);
140+
if (result == null) { return null; }
141+
return double.Parse(result);
142+
}
143+
128144
/// <summary>
129145
/// Gets a configuration property enum value given a key.
130146
/// </summary>

src/Confluent.Kafka/Config_gen.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// *** Auto-generated from librdkafka 7632802d315b1a10f27e957400a3ec74f12ffbe8 *** - do not modify manually.
1+
// *** Auto-generated from librdkafka v1.2.1 *** - do not modify manually.
22
//
33
// Copyright 2018 Confluent Inc.
44
//
@@ -943,7 +943,7 @@ public ProducerConfig(IDictionary<string, string> config) : base(config) { }
943943
/// default: 0.5
944944
/// importance: high
945945
/// </summary>
946-
public double? LingerMs { get { return (double?)GetEnum(typeof(double), "linger.ms"); } set { this.SetObject("linger.ms", value); } }
946+
public double? LingerMs { get { return GetDouble("linger.ms"); } set { this.SetObject("linger.ms", value); } }
947947

948948
/// <summary>
949949
/// How many times to retry sending a failing Message. **Note:** retrying may cause reordering unless `enable.idempotence` is set to true.
@@ -1174,7 +1174,7 @@ public ConsumerConfig(IDictionary<string, string> config) : base(config) { }
11741174
/// <summary>
11751175
/// Controls how to read messages written transactionally: `read_committed` - only return transactional messages which have been committed. `read_uncommitted` - return all messages, even transactional messages which have been aborted.
11761176
///
1177-
/// default: read_uncommitted
1177+
/// default: read_committed
11781178
/// importance: high
11791179
/// </summary>
11801180
public IsolationLevel? IsolationLevel { get { return (IsolationLevel?)GetEnum(typeof(IsolationLevel), "isolation.level"); } set { this.SetObject("isolation.level", value); } }

test/Confluent.Kafka.IntegrationTests/Tests/Producer_Produce.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public void Producer_Produce(string bootstrapServers)
3636
var producerConfig = new ProducerConfig
3737
{
3838
BootstrapServers = bootstrapServers,
39-
EnableIdempotence = true
39+
EnableIdempotence = true,
40+
LingerMs = 1.5
4041
};
4142

4243

0 commit comments

Comments
 (0)