Skip to content

Commit

Permalink
refactor: changes to file scoped namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoRodriguesGithub committed Dec 12, 2023
1 parent 539a007 commit aff26ac
Show file tree
Hide file tree
Showing 326 changed files with 13,704 additions and 14,028 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_namespace_declarations = file_scoped:error
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
Expand Down
13 changes: 6 additions & 7 deletions samples/KafkaFlow.Sample.FlowControl/PrintConsoleMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace KafkaFlow.Sample.FlowControl
namespace KafkaFlow.Sample.FlowControl;

internal class PrintConsoleMiddleware : IMessageMiddleware
{
internal class PrintConsoleMiddleware : IMessageMiddleware
public Task Invoke(IMessageContext context, MiddlewareDelegate next)
{
public Task Invoke(IMessageContext context, MiddlewareDelegate next)
{
Console.WriteLine($"Message: {JsonConvert.SerializeObject(context.Message.Value)}");
return Task.CompletedTask;
}
Console.WriteLine($"Message: {JsonConvert.SerializeObject(context.Message.Value)}");
return Task.CompletedTask;
}
}
11 changes: 5 additions & 6 deletions samples/KafkaFlow.Sample.FlowControl/SampleMessage.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System;

namespace KafkaFlow.Sample.FlowControl
namespace KafkaFlow.Sample.FlowControl;

internal class SampleMessage
{
internal class SampleMessage
{
public Guid Id { get; set; }
public Guid Id { get; set; }

public string Name { get; set; }
}
public string Name { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
using System.Threading.Tasks;
using global::SchemaRegistry;

namespace KafkaFlow.Sample.SchemaRegistry.Handlers
namespace KafkaFlow.Sample.SchemaRegistry.Handlers;

public class AvroMessageHandler : IMessageHandler<AvroLogMessage>
{
public class AvroMessageHandler : IMessageHandler<AvroLogMessage>
public Task Handle(IMessageContext context, AvroLogMessage message)
{
public Task Handle(IMessageContext context, AvroLogMessage message)
{
Console.WriteLine(
"Partition: {0} | Offset: {1} | Message: {2} | Avro",
context.ConsumerContext.Partition,
context.ConsumerContext.Offset,
message.Severity.ToString());
Console.WriteLine(
"Partition: {0} | Offset: {1} | Message: {2} | Avro",
context.ConsumerContext.Partition,
context.ConsumerContext.Offset,
message.Severity.ToString());

return Task.CompletedTask;
}
return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
using Newtonsoft.Json;

namespace SchemaRegistry
namespace SchemaRegistry;

/// <summary>
/// A simple log message.
/// </summary>
public class JsonLogMessage
{
/// <summary>
/// A simple log message.
/// </summary>
public class JsonLogMessage
{
[JsonProperty]
public string Message { get; set; }
[JsonProperty]
public string Message { get; set; }

[JsonProperty]
public string Type { get; set; }
}
[JsonProperty]
public string Type { get; set; }
}
21 changes: 10 additions & 11 deletions src/KafkaFlow.Abstractions/Acks.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
namespace KafkaFlow
namespace KafkaFlow;

/// <summary>Acknowledge type</summary>
public enum Acks
{
/// <summary>Acknowledge type</summary>
public enum Acks
{
/// <summary>Only waits leader's acknowledge</summary>
Leader,
/// <summary>Only waits leader's acknowledge</summary>
Leader,

/// <summary>Waits acknowledge from all brokers</summary>
All,
/// <summary>Waits acknowledge from all brokers</summary>
All,

/// <summary>Don't wait acknowledge</summary>
None,
}
/// <summary>Don't wait acknowledge</summary>
None,
}
17 changes: 8 additions & 9 deletions src/KafkaFlow.Abstractions/AutoOffsetReset.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
namespace KafkaFlow
namespace KafkaFlow;

/// <summary>AutoOffsetReset enum values</summary>
public enum AutoOffsetReset
{
/// <summary>AutoOffsetReset enum values</summary>
public enum AutoOffsetReset
{
/// <summary>Only reads new messages in the topic</summary>
Latest,
/// <summary>Only reads new messages in the topic</summary>
Latest,

/// <summary>Reads the topic from the beginning</summary>
Earliest,
}
/// <summary>Reads the topic from the beginning</summary>
Earliest,
}
Original file line number Diff line number Diff line change
@@ -1,86 +1,85 @@
using System;
using System.Collections.Generic;

namespace KafkaFlow.Configuration
namespace KafkaFlow.Configuration;

/// <summary>
/// A interface to build the cluster configuration
/// </summary>
public interface IClusterConfigurationBuilder
{
/// <summary>
/// A interface to build the cluster configuration
/// Gets the dependency injection configurator
/// </summary>
public interface IClusterConfigurationBuilder
{
/// <summary>
/// Gets the dependency injection configurator
/// </summary>
IDependencyConfigurator DependencyConfigurator { get; }
IDependencyConfigurator DependencyConfigurator { get; }

/// <summary>
/// Set the Kafka Brokers to be used
/// </summary>
/// <param name="brokers">The brokers address to be used</param>
/// <returns></returns>
IClusterConfigurationBuilder WithBrokers(IEnumerable<string> brokers);
/// <summary>
/// Set the Kafka Brokers to be used
/// </summary>
/// <param name="brokers">The brokers address to be used</param>
/// <returns></returns>
IClusterConfigurationBuilder WithBrokers(IEnumerable<string> brokers);

/// <summary>
/// Sets a unique name for the cluster
/// </summary>
/// <param name="name">A unique name</param>
/// <returns></returns>
IClusterConfigurationBuilder WithName(string name);
/// <summary>
/// Sets a unique name for the cluster
/// </summary>
/// <param name="name">A unique name</param>
/// <returns></returns>
IClusterConfigurationBuilder WithName(string name);

/// <summary>
/// Configures cluster security
/// </summary>
/// <param name="handler">A handler to sets the values</param>
/// <returns></returns>
IClusterConfigurationBuilder WithSecurityInformation(Action<SecurityInformation> handler);
/// <summary>
/// Configures cluster security
/// </summary>
/// <param name="handler">A handler to sets the values</param>
/// <returns></returns>
IClusterConfigurationBuilder WithSecurityInformation(Action<SecurityInformation> handler);

/// <summary>
/// Adds a producer to the cluster
/// </summary>
/// <param name="producer">A handler to configure the producer</param>
/// <typeparam name="TProducer">A type used to get the internal producer instance</typeparam>
/// <returns></returns>
IClusterConfigurationBuilder AddProducer<TProducer>(Action<IProducerConfigurationBuilder> producer);
/// <summary>
/// Adds a producer to the cluster
/// </summary>
/// <param name="producer">A handler to configure the producer</param>
/// <typeparam name="TProducer">A type used to get the internal producer instance</typeparam>
/// <returns></returns>
IClusterConfigurationBuilder AddProducer<TProducer>(Action<IProducerConfigurationBuilder> producer);

/// <summary>
/// Adds a producer to the cluster
/// </summary>
/// <param name="name">The producer name used to get its instance</param>
/// <param name="producer">A handler to configure the producer</param>
/// <returns></returns>
IClusterConfigurationBuilder AddProducer(string name, Action<IProducerConfigurationBuilder> producer);
/// <summary>
/// Adds a producer to the cluster
/// </summary>
/// <param name="name">The producer name used to get its instance</param>
/// <param name="producer">A handler to configure the producer</param>
/// <returns></returns>
IClusterConfigurationBuilder AddProducer(string name, Action<IProducerConfigurationBuilder> producer);

/// <summary>
/// Adds a consumer to the cluster
/// </summary>
/// <param name="consumer">A handler to configure the consumer</param>
/// <returns></returns>
IClusterConfigurationBuilder AddConsumer(Action<IConsumerConfigurationBuilder> consumer);
/// <summary>
/// Adds a consumer to the cluster
/// </summary>
/// <param name="consumer">A handler to configure the consumer</param>
/// <returns></returns>
IClusterConfigurationBuilder AddConsumer(Action<IConsumerConfigurationBuilder> consumer);

/// <summary>
/// Adds a handler to be executed when KafkaFlow cluster is stopping
/// </summary>
/// <param name="handler">A handler to KafkaFlow cluster stopping event</param>
/// <returns></returns>
IClusterConfigurationBuilder OnStopping(Action<IDependencyResolver> handler);
/// <summary>
/// Adds a handler to be executed when KafkaFlow cluster is stopping
/// </summary>
/// <param name="handler">A handler to KafkaFlow cluster stopping event</param>
/// <returns></returns>
IClusterConfigurationBuilder OnStopping(Action<IDependencyResolver> handler);

/// <summary>
/// Adds a handler to be executed after KafkaFlow cluster started
/// </summary>
/// <param name="handler">A handler to KafkaFlow cluster started event</param>
/// <returns></returns>
IClusterConfigurationBuilder OnStarted(Action<IDependencyResolver> handler);
/// <summary>
/// Adds a handler to be executed after KafkaFlow cluster started
/// </summary>
/// <param name="handler">A handler to KafkaFlow cluster started event</param>
/// <returns></returns>
IClusterConfigurationBuilder OnStarted(Action<IDependencyResolver> handler);

/// <summary>
/// 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>
/// <returns></returns>
IClusterConfigurationBuilder CreateTopicIfNotExists(
string topicName,
int numberOfPartitions,
short replicationFactor);
}
/// <summary>
/// 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>
/// <returns></returns>
IClusterConfigurationBuilder CreateTopicIfNotExists(
string topicName,
int numberOfPartitions,
short replicationFactor);
}
Loading

0 comments on commit aff26ac

Please sign in to comment.