Skip to content

Commit

Permalink
feat: allow use of cluster defined values for topic creation
Browse files Browse the repository at this point in the history
robertcoltheart authored and ruiqbarbosa committed Apr 15, 2024
1 parent 188b21d commit 6ede5c7
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -75,11 +75,11 @@ public interface IClusterConfigurationBuilder
/// Adds a Topic to the Cluster
/// </summary>
/// <param name="topicName">The topic name</param>
/// <param name="numberOfPartitions">The number of Topic partitions</param>
/// <param name="replicationFactor">The Topic replication factor</param>
/// <param name="numberOfPartitions">The number of Topic partitions. Default is to use the cluster-defined partitions.</param>
/// <param name="replicationFactor">The Topic replication factor. Default is to use the cluster-defined replication factor.</param>
/// <returns></returns>
IClusterConfigurationBuilder CreateTopicIfNotExists(
string topicName,
int numberOfPartitions,
short replicationFactor);
int numberOfPartitions = -1,
short replicationFactor = -1);
}
4 changes: 2 additions & 2 deletions src/KafkaFlow/Configuration/ClusterConfigurationBuilder.cs
Original file line number Diff line number Diff line change
@@ -110,8 +110,8 @@ public IClusterConfigurationBuilder OnStarted(Action<IDependencyResolver> handle

public IClusterConfigurationBuilder CreateTopicIfNotExists(
string topicName,
int numberOfPartitions,
short replicationFactor)
int numberOfPartitions = -1,
short replicationFactor = -1)
{
_topicsToCreateIfNotExist.Add(new TopicConfiguration(topicName, numberOfPartitions, replicationFactor));
return this;
2 changes: 2 additions & 0 deletions tests/KafkaFlow.IntegrationTests/Core/Bootstrapper.cs
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ internal static class Bootstrapper
private const string ProtobufGzipTopicName2 = "test-protobuf-gzip-2";
private const string AvroTopicName = "test-avro";
private const string NullTopicName = "test-null";
private const string DefaultParamsTopicName = "test-default-params";

private static readonly Lazy<IServiceProvider> s_lazyProvider = new(SetupProvider);

@@ -202,6 +203,7 @@ private static void SetupServices(HostBuilderContext context, IServiceCollection
.CreateTopicIfNotExists(ProtobufGzipTopicName, 2, 1)
.CreateTopicIfNotExists(ProtobufGzipTopicName2, 2, 1)
.CreateTopicIfNotExists(NullTopicName, 1, 1)
.CreateTopicIfNotExists(DefaultParamsTopicName)
.AddConsumer(
consumer => consumer
.Topic(ProtobufTopicName)

0 comments on commit 6ede5c7

Please sign in to comment.