Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow use of cluster defined values for topic creation #555

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tests/KafkaFlow.IntegrationTests/Core/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down
Loading