Skip to content

Commit

Permalink
Rename IEventBusConsumer and IEventBusConsumer<T> to IEventConsumer a…
Browse files Browse the repository at this point in the history
…nd IEventConsumer<T>
  • Loading branch information
mburumaxwell committed Jan 10, 2021
1 parent 966d3e9 commit 9b7c214
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion examples/CustomSerializer/AzureDevOpsEventsConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace CustomSerializer
{
internal class AzureDevOpsEventsConsumer : IEventBusConsumer<AzureDevOpsCodePushed>
internal class AzureDevOpsEventsConsumer : IEventConsumer<AzureDevOpsCodePushed>
{
private readonly ILogger logger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace InMemoryBackgroundProcessing
{
public class VideoUploadedConsumer : IEventBusConsumer<VideoUploaded>
public class VideoUploadedConsumer : IEventConsumer<VideoUploaded>
{
private static readonly TimeSpan SimulationDuration = TimeSpan.FromSeconds(3);

Expand Down
2 changes: 1 addition & 1 deletion examples/MultiEventsConsumer/MultiEventsConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace MultiEventsConsumer
{
public class MultiEventsConsumer : IEventBusConsumer<DoorClosed>, IEventBusConsumer<DoorOpened>
public class MultiEventsConsumer : IEventConsumer<DoorClosed>, IEventConsumer<DoorOpened>
{
private static readonly TimeSpan SimulationDuration = TimeSpan.FromSeconds(3);

Expand Down
2 changes: 1 addition & 1 deletion examples/SimpleConsumer/SampleEventConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace SimpleConsumer
{
public class SampleEventConsumer : IEventBusConsumer<SampleEvent>
public class SampleEventConsumer : IEventConsumer<SampleEvent>
{
private readonly EventCounter counter;
private readonly ILogger logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private async Task OnMessageReceivedAsync<TEvent, TConsumer>(ConsumerRegistratio
Message message,
CancellationToken cancellationToken)
where TEvent : class
where TConsumer : IEventBusConsumer<TEvent>
where TConsumer : IEventConsumer<TEvent>
{
var messageId = message.MessageId;
message.TryGetAttribute(AttributeNames.CorrelationId, out var correlationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private async Task<EventProcessorClient> GetProcessorAsync(ConsumerRegistration

private async Task OnEventReceivedAsync<TEvent, TConsumer>(ConsumerRegistration reg, EventProcessorClient processor, ProcessEventArgs args)
where TEvent : class
where TConsumer : IEventBusConsumer<TEvent>
where TConsumer : IEventConsumer<TEvent>
{
if (!args.HasEvent)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ private async Task OnMessageReceivedAsync<TEvent, TConsumer>(ConsumerRegistratio
IServiceScope scope,
CancellationToken cancellationToken)
where TEvent : class
where TConsumer : IEventBusConsumer<TEvent>
where TConsumer : IEventConsumer<TEvent>
{
var messageId = message.MessageId;
using var log_scope = Logger.BeginScopeForConsume(id: messageId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ private async Task CreateSubscriptionIfNotExistsAsync(string topicName, string s

private async Task OnMessageReceivedAsync<TEvent, TConsumer>(ConsumerRegistration reg, ProcessMessageEventArgs args)
where TEvent : class
where TConsumer : IEventBusConsumer<TEvent>
where TConsumer : IEventConsumer<TEvent>
{
var message = args.Message;
var messageId = message.MessageId;
Expand Down
2 changes: 1 addition & 1 deletion src/Tingle.EventBus.Transports.Kafka/KafkaTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private async Task OnEventReceivedAsync<TEvent, TConsumer>(ConsumerRegistration
Message<string, byte[]> message,
CancellationToken cancellationToken)
where TEvent : class
where TConsumer : IEventBusConsumer<TEvent>
where TConsumer : IEventConsumer<TEvent>
{
var messageKey = message.Key;
message.Headers.TryGetValue(AttributeNames.CorrelationId, out var correlationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class KafkaTransportOptions: EventBusTransportOptionsBase
/// <summary>
/// The number of events consumed after which to checkpoint.
/// For values other than <c>1</c>, the implementations of
/// <see cref="IEventBusConsumer{T}"/> for Kafka events must
/// <see cref="IEventConsumer{T}"/> for Kafka events must
/// handle duplicate detection.
/// </summary>
/// <remarks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private async Task ConnectConsumersAsync(CancellationToken cancellationToken)

private async Task OnMessageReceivedAsync<TEvent, TConsumer>(ConsumerRegistration reg, IModel channel, BasicDeliverEventArgs args, CancellationToken cancellationToken)
where TEvent : class
where TConsumer : IEventBusConsumer<TEvent>
where TConsumer : IEventConsumer<TEvent>
{
var messageId = args.BasicProperties?.MessageId;
using var log_scope = Logger.BeginScopeForConsume(id: messageId,
Expand Down
8 changes: 4 additions & 4 deletions src/Tingle.EventBus/DependencyInjection/EventBusBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public EventBusBuilder UseDefaultSerializer<TEventSerializer>() where TEventSeri
/// design of <typeparamref name="TConsumer"/>.
/// </param>
/// <returns></returns>
public EventBusBuilder AddConsumer<TConsumer>(ServiceLifetime lifetime = ServiceLifetime.Scoped) where TConsumer : class, IEventBusConsumer
public EventBusBuilder AddConsumer<TConsumer>(ServiceLifetime lifetime = ServiceLifetime.Scoped) where TConsumer : class, IEventConsumer
{
var consumerType = typeof(TConsumer);
if (consumerType.IsAbstract)
Expand All @@ -130,7 +130,7 @@ public EventBusBuilder AddConsumer<TConsumer>(ServiceLifetime lifetime = Service
// register the consumer for resolution
Services.Add(ServiceDescriptor.Describe(consumerType, consumerType, lifetime));

var genericConsumerType = typeof(IEventBusConsumer<>);
var genericConsumerType = typeof(IEventConsumer<>);
var eventTypes = new List<Type>();

// get events from each implementation of IEventConsumer<TEvent>
Expand All @@ -152,7 +152,7 @@ public EventBusBuilder AddConsumer<TConsumer>(ServiceLifetime lifetime = Service
// we must have at least one implemented event
if (eventTypes.Count <= 0)
{
throw new InvalidOperationException($"{consumerType.FullName} must implement '{nameof(IEventBusConsumer)}<TEvent>' at least once.");
throw new InvalidOperationException($"{consumerType.FullName} must implement '{nameof(IEventConsumer)}<TEvent>' at least once.");
}

// add the event types to the registrations
Expand All @@ -177,7 +177,7 @@ public EventBusBuilder AddConsumer<TConsumer>(ServiceLifetime lifetime = Service
/// </summary>
/// <typeparam name="TConsumer"></typeparam>
/// <returns></returns>
public EventBusBuilder RemoveConsumer<TConsumer>() where TConsumer : class, IEventBusConsumer
public EventBusBuilder RemoveConsumer<TConsumer>() where TConsumer : class, IEventConsumer
{
// Deregister from services collection
Services.RemoveAll<TConsumer>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ namespace Tingle.EventBus
/// <summary>
/// Contract describing a consumer of one or more events.
/// </summary>
public interface IEventBusConsumer
public interface IEventConsumer
{
// Intentionally left blank
}

/// <summary>
/// Contract describing a consumer of an event.
/// </summary>
public interface IEventBusConsumer<T> : IEventBusConsumer
public interface IEventConsumer<T> : IEventConsumer
{
/// <summary>
/// Consume an event of the provided type.
Expand Down
2 changes: 1 addition & 1 deletion src/Tingle.EventBus/Transports/EventBusTransportBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected async Task SerializeAsync<TEvent>(Stream body,
protected async Task ConsumeAsync<TEvent, TConsumer>(EventContext<TEvent> @event,
IServiceScope scope,
CancellationToken cancellationToken)
where TConsumer : IEventBusConsumer<TEvent>
where TConsumer : IEventConsumer<TEvent>
{
// Resolve the consumer
var consumer = scope.ServiceProvider.GetRequiredService<TConsumer>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private async Task OnMessageReceivedAsync<TEvent, TConsumer>(ConsumerRegistratio
IServiceScope scope,
CancellationToken cancellationToken)
where TEvent : class
where TConsumer : IEventBusConsumer<TEvent>
where TConsumer : IEventConsumer<TEvent>
{
var messageId = message.MessageId;

Expand Down
4 changes: 2 additions & 2 deletions tests/Tingle.EventBus.Tests/RegistrationExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public Task SerializeAsync<T>(Stream stream, EventContext<T> context, HostInfo h

class DummyEventSerializer2 { } // should not implement IEventSerializer

class TestConsumer1 : IEventBusConsumer<TestEvent1>
class TestConsumer1 : IEventConsumer<TestEvent1>
{
public Task ConsumeAsync(EventContext<TestEvent1> context, CancellationToken cancellationToken = default)
{
Expand All @@ -210,7 +210,7 @@ public Task ConsumeAsync(EventContext<TestEvent1> context, CancellationToken can
}

[ConsumerName("sample-consumer")]
class TestConsumer2 : IEventBusConsumer<TestEvent2>
class TestConsumer2 : IEventConsumer<TestEvent2>
{
public Task ConsumeAsync(EventContext<TestEvent2> context, CancellationToken cancellationToken = default)
{
Expand Down

0 comments on commit 9b7c214

Please sign in to comment.