Skip to content

Commit

Permalink
refactor: Change private variable to use underscore
Browse files Browse the repository at this point in the history
JIRA GOE-1859
  • Loading branch information
brmagadutra committed Nov 23, 2023
1 parent 66bd7d4 commit 1583857
Show file tree
Hide file tree
Showing 46 changed files with 290 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ namespace KafkaFlow.Sample.PauseConsumerOnError;

public class PauseConsumerOnExceptionMiddleware : IMessageMiddleware
{
private readonly IConsumerAccessor consumerAccessor;
private readonly ILogHandler logHandler;
private readonly IConsumerAccessor _consumerAccessor;
private readonly ILogHandler _logHandler;

public PauseConsumerOnExceptionMiddleware(IConsumerAccessor consumerAccessor, ILogHandler logHandler)
{
this.consumerAccessor = consumerAccessor;
this.logHandler = logHandler;
this._consumerAccessor = consumerAccessor;
this._logHandler = logHandler;
}

public async Task Invoke(IMessageContext context, MiddlewareDelegate next)
Expand All @@ -22,7 +22,7 @@ public async Task Invoke(IMessageContext context, MiddlewareDelegate next)
catch (Exception exception)
{
context.ConsumerContext.AutoMessageCompletion = false;
this.logHandler.Error("Error handling message", exception,
this._logHandler.Error("Error handling message", exception,
new
{
context.Message,
Expand All @@ -31,10 +31,10 @@ public async Task Invoke(IMessageContext context, MiddlewareDelegate next)
context.ConsumerContext.ConsumerName,
});

var consumer = this.consumerAccessor[context.ConsumerContext.ConsumerName];
var consumer = this._consumerAccessor[context.ConsumerContext.ConsumerName];
consumer.Pause(consumer.Assignment);

this.logHandler.Warning("Consumer stopped", context.ConsumerContext.ConsumerName);
this._logHandler.Warning("Consumer stopped", context.ConsumerContext.ConsumerName);
}
}
}
12 changes: 6 additions & 6 deletions src/KafkaFlow.Admin.Dashboard/DashboardConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ namespace KafkaFlow.Admin.Dashboard
{
internal class DashboardConfigurationBuilder : IDashboardConfigurationBuilder
{
private readonly PathString basePath = "/kafkaflow";
private readonly PathString _basePath = "/kafkaflow";

private Action<IApplicationBuilder> requestHandler = _ => { };
private Action<IEndpointConventionBuilder> endpointHandler = _ => { };
private Action<IApplicationBuilder> _requestHandler = _ => { };
private Action<IEndpointConventionBuilder> _endpointHandler = _ => { };

public IDashboardConfigurationBuilder ConfigureRequestPipeline(Action<IApplicationBuilder> requestHandler)
{
this.requestHandler = requestHandler;
this._requestHandler = requestHandler;
return this;
}

public IDashboardConfigurationBuilder ConfigureEndpoint(Action<IEndpointConventionBuilder> endpointHandler)
{
this.endpointHandler = endpointHandler;
this._endpointHandler = endpointHandler;
return this;
}

public DashboardConfiguration Build()
{
return new(this.basePath, this.requestHandler, this.endpointHandler);
return new(this._basePath, this._requestHandler, this._endpointHandler);
}
}
}
44 changes: 22 additions & 22 deletions src/KafkaFlow.Admin.WebApi/Controllers/ConsumersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace KafkaFlow.Admin.WebApi.Controllers
[ApiController]
public class ConsumersController : ControllerBase
{
private readonly IConsumerAccessor consumers;
private readonly IConsumerAdmin consumerAdmin;
private readonly IConsumerAccessor _consumers;
private readonly IConsumerAdmin _consumerAdmin;

/// <summary>
/// Initializes a new instance of the <see cref="ConsumersController"/> class.
Expand All @@ -25,8 +25,8 @@ public class ConsumersController : ControllerBase
/// <param name="consumerAdmin">The admin messages consumer</param>
public ConsumersController(IConsumerAccessor consumers, IConsumerAdmin consumerAdmin)
{
this.consumers = consumers;
this.consumerAdmin = consumerAdmin;
this._consumers = consumers;
this._consumerAdmin = consumerAdmin;
}

/// <summary>
Expand All @@ -41,7 +41,7 @@ public IActionResult GetConsumersByGroupId([FromRoute] string groupId)
return this.Ok(
new ConsumersResponse
{
Consumers = this.consumers
Consumers = this._consumers
.All
.Where(x => x.GroupId == groupId)
.Select(x => x.Adapt()),
Expand All @@ -62,7 +62,7 @@ public IActionResult GetConsumerByGroupIdName(
[FromRoute] string groupId,
[FromRoute] string consumerName)
{
var consumer = this.consumers.All
var consumer = this._consumers.All
.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);

if (consumer is null)
Expand All @@ -89,15 +89,15 @@ public async Task<IActionResult> PauseConsumer(
[FromRoute] string consumerName,
[FromQuery] IList<string> topics)
{
var consumer = this.consumers.All
var consumer = this._consumers.All
.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);

if (consumer is null)
{
return this.NotFound();
}

await this.consumerAdmin.PauseConsumerAsync(consumerName, topics);
await this._consumerAdmin.PauseConsumerAsync(consumerName, topics);

return this.Accepted();
}
Expand All @@ -118,15 +118,15 @@ public async Task<IActionResult> ResumeConsumer(
[FromRoute] string consumerName,
[FromQuery] IList<string> topics)
{
var consumer = this.consumers.All
var consumer = this._consumers.All
.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);

if (consumer is null)
{
return this.NotFound();
}

await this.consumerAdmin.ResumeConsumerAsync(consumerName, topics);
await this._consumerAdmin.ResumeConsumerAsync(consumerName, topics);

return this.Accepted();
}
Expand All @@ -145,14 +145,14 @@ public async Task<IActionResult> StartConsumer(
[FromRoute] string groupId,
[FromRoute] string consumerName)
{
var consumer = this.consumers.All.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);
var consumer = this._consumers.All.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);

if (consumer is null)
{
return this.NotFound();
}

await this.consumerAdmin.StartConsumerAsync(consumerName);
await this._consumerAdmin.StartConsumerAsync(consumerName);

return this.Accepted();
}
Expand All @@ -171,14 +171,14 @@ public async Task<IActionResult> StopConsumer(
[FromRoute] string groupId,
[FromRoute] string consumerName)
{
var consumer = this.consumers.All.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);
var consumer = this._consumers.All.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);

if (consumer is null)
{
return this.NotFound();
}

await this.consumerAdmin.StopConsumerAsync(consumerName);
await this._consumerAdmin.StopConsumerAsync(consumerName);

return this.Accepted();
}
Expand All @@ -197,15 +197,15 @@ public async Task<IActionResult> RestartConsumer(
[FromRoute] string groupId,
[FromRoute] string consumerName)
{
var consumer = this.consumers.All
var consumer = this._consumers.All
.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);

if (consumer is null)
{
return this.NotFound();
}

await this.consumerAdmin.RestartConsumerAsync(consumerName);
await this._consumerAdmin.RestartConsumerAsync(consumerName);

return this.Accepted();
}
Expand Down Expand Up @@ -234,15 +234,15 @@ public async Task<IActionResult> ResetOffsets(
return this.BadRequest();
}

var consumer = this.consumers.All
var consumer = this._consumers.All
.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);

if (consumer is null)
{
return this.NotFound();
}

await this.consumerAdmin.ResetOffsetsAsync(consumerName, topics);
await this._consumerAdmin.ResetOffsetsAsync(consumerName, topics);

return this.Accepted();
}
Expand Down Expand Up @@ -271,15 +271,15 @@ public async Task<IActionResult> RewindOffsets(
return this.BadRequest();
}

var consumer = this.consumers.All
var consumer = this._consumers.All
.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);

if (consumer is null)
{
return this.NotFound();
}

await this.consumerAdmin.RewindOffsetsAsync(consumerName, request.Date, topics);
await this._consumerAdmin.RewindOffsetsAsync(consumerName, request.Date, topics);

return this.Accepted();
}
Expand All @@ -306,15 +306,15 @@ public async Task<IActionResult> ChangeWorkersCount(
return this.BadRequest();
}

var consumer = this.consumers.All
var consumer = this._consumers.All
.FirstOrDefault(x => x.GroupId == groupId && x.ConsumerName == consumerName);

if (consumer is null)
{
return this.NotFound();
}

await this.consumerAdmin.ChangeWorkersCountAsync(consumerName, request.WorkersCount);
await this._consumerAdmin.ChangeWorkersCountAsync(consumerName, request.WorkersCount);

return this.Accepted();
}
Expand Down
14 changes: 7 additions & 7 deletions src/KafkaFlow.Admin.WebApi/Controllers/GroupsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace KafkaFlow.Admin.WebApi.Controllers
[ApiController]
public class GroupsController : ControllerBase
{
private readonly IConsumerAccessor consumers;
private readonly IConsumerAdmin consumerAdmin;
private readonly IConsumerAccessor _consumers;
private readonly IConsumerAdmin _consumerAdmin;

/// <summary>
/// Initializes a new instance of the <see cref="GroupsController"/> class.
Expand All @@ -25,8 +25,8 @@ public class GroupsController : ControllerBase
/// <param name="consumerAdmin">The admin messages consumer</param>
public GroupsController(IConsumerAccessor consumers, IConsumerAdmin consumerAdmin)
{
this.consumers = consumers;
this.consumerAdmin = consumerAdmin;
this._consumers = consumers;
this._consumerAdmin = consumerAdmin;
}

/// <summary>
Expand All @@ -40,7 +40,7 @@ public IActionResult GetAllGroups()
return this.Ok(
new GroupsResponse
{
Groups = this.consumers.All
Groups = this._consumers.All
.GroupBy(x => x.GroupId)
.Select(
x => new GroupResponse
Expand All @@ -64,7 +64,7 @@ public async Task<IActionResult> PauseGroup(
[FromRoute] string groupId,
[FromQuery] IList<string> topics)
{
await this.consumerAdmin.PauseConsumerGroupAsync(groupId, topics);
await this._consumerAdmin.PauseConsumerGroupAsync(groupId, topics);

return this.Accepted();
}
Expand All @@ -82,7 +82,7 @@ public async Task<IActionResult> ResumeGroup(
[FromRoute] string groupId,
[FromQuery] IList<string> topics)
{
await this.consumerAdmin.ResumeConsumerGroupAsync(groupId, topics);
await this._consumerAdmin.ResumeConsumerGroupAsync(groupId, topics);

return this.Accepted();
}
Expand Down
6 changes: 3 additions & 3 deletions src/KafkaFlow.Admin.WebApi/Controllers/TelemetryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ namespace KafkaFlow.Admin.WebApi.Controllers
[ApiController]
public class TelemetryController : ControllerBase
{
private readonly ITelemetryStorage storage;
private readonly ITelemetryStorage _storage;

/// <summary>
/// Initializes a new instance of the <see cref="TelemetryController"/> class.
/// </summary>
/// <param name="storage">The telemetry storage</param>
public TelemetryController(ITelemetryStorage storage)
{
this.storage = storage;
this._storage = storage;
}

/// <summary>
Expand All @@ -30,7 +30,7 @@ public TelemetryController(ITelemetryStorage storage)
[ProducesResponseType(typeof(TelemetryResponse), 200)]
public IActionResult GetTelemetry()
{
var metrics = this.storage.Get();
var metrics = this._storage.Get();

return this.Ok(metrics.Adapt());
}
Expand Down
10 changes: 5 additions & 5 deletions src/KafkaFlow.Admin/AdminProducer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ namespace KafkaFlow.Admin
{
internal class AdminProducer : IAdminProducer
{
private readonly IMessageProducer<AdminProducer> producer;
private readonly int topicPartition;
private readonly IMessageProducer<AdminProducer> _producer;
private readonly int _topicPartition;

public AdminProducer(IMessageProducer<AdminProducer> producer, int topicPartition)
{
this.producer = producer;
this.topicPartition = topicPartition;
this._producer = producer;
this._topicPartition = topicPartition;
}

public Task ProduceAsync(IAdminMessage message) =>
this.producer.ProduceAsync(Guid.NewGuid().ToString(), message, partition: this.topicPartition);
this._producer.ProduceAsync(Guid.NewGuid().ToString(), message, partition: this._topicPartition);
}
}
Loading

0 comments on commit 1583857

Please sign in to comment.