Skip to content

Commit 3e97d24

Browse files
committed
Fixing nullable attribute properties in KafgkaAttribute.
1 parent 32b56a7 commit 3e97d24

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Microsoft.Azure.WebJobs.Extensions.Kafka/Output/KafkaAttribute.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ namespace Microsoft.Azure.WebJobs.Extensions.Kafka
1515
[Binding]
1616
public sealed class KafkaAttribute : Attribute
1717
{
18+
private int? maxMessageBytes;
19+
private int? batchSize;
20+
private bool? enableIdempotence;
21+
private int? messageTimeoutMs;
22+
private int? requestTimeoutMs;
23+
private int? maxRetries;
24+
1825
/// <summary>
1926
/// Initialize a new instance of the <see cref="KafkaAttribute"/>
2027
/// </summary>
@@ -54,33 +61,33 @@ public KafkaAttribute()
5461
/// <summary>
5562
/// Gets or sets the Maximum transmit message size. Default: 1MB
5663
/// </summary>
57-
public int? MaxMessageBytes { get; set; }
64+
public int MaxMessageBytes { get => maxMessageBytes.GetValueOrDefault(1000000); set => maxMessageBytes = value; }
5865

5966
/// <summary>
6067
/// Maximum number of messages batched in one MessageSet. default: 10000
6168
/// </summary>
62-
public int? BatchSize { get; set; }
69+
public int BatchSize { get => batchSize.GetValueOrDefault(10000); set => batchSize = value; }
6370

6471
/// <summary>
6572
/// When set to `true`, the producer will ensure that messages are successfully produced exactly once and in the original produce order. default: false
6673
/// </summary>
67-
public bool? EnableIdempotence { get; set; }
74+
public bool EnableIdempotence { get => enableIdempotence.GetValueOrDefault(false); set => enableIdempotence = value; }
6875

6976
/// <summary>
7077
/// Local message timeout. This value is only enforced locally and limits the time a produced message waits for successful delivery. A time of 0 is infinite. This is the maximum time used to deliver a message (including retries). Delivery error occurs when either the retry count or the message timeout are exceeded. default: 300000
7178
/// </summary>
72-
public int? MessageTimeoutMs { get; set; }
79+
public int MessageTimeoutMs { get => messageTimeoutMs.GetValueOrDefault(300000); set => messageTimeoutMs = value; }
7380

7481
/// <summary>
7582
/// The ack timeout of the producer request in milliseconds. default: 5000
7683
/// </summary>
77-
public int? RequestTimeoutMs { get; set; }
84+
public int RequestTimeoutMs { get => requestTimeoutMs.GetValueOrDefault(5000); set => requestTimeoutMs = value; }
7885

7986
/// <summary>
8087
/// How many times to retry sending a failing Message. **Note:** default: 2
8188
/// </summary>
8289
/// <remarks>Retrying may cause reordering unless <c>EnableIdempotence</c> is set to <c>true</c>.</remarks>
83-
public int? MaxRetries { get; set; }
90+
public int MaxRetries { get => maxRetries.GetValueOrDefault(2); set => maxRetries = value; }
8491

8592
/// <summary>
8693
/// SASL mechanism to use for authentication.

0 commit comments

Comments
 (0)