Skip to content

Commit

Permalink
Rename EventBusBuilder.RegisterTransport(...) to AddTransport(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell committed Jan 10, 2021
1 parent 1a628af commit 966d3e9
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static EventBusBuilder AddAmazonKinesisTransport(this EventBusBuilder bui
});

// Register the transport
builder.RegisterTransport<AmazonKinesisTransport, AmazonKinesisTransportOptions>();
builder.AddTransport<AmazonKinesisTransport, AmazonKinesisTransportOptions>();

return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static EventBusBuilder AddAmazonSqsTransport(this EventBusBuilder builder
});

// register the transport
builder.RegisterTransport<AmazonSqsTransport, AmazonSqsTransportOptions>();
builder.AddTransport<AmazonSqsTransport, AmazonSqsTransportOptions>();

return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static EventBusBuilder AddAzureEventHubsTransport(this EventBusBuilder bu
services.AddSingleton<IPostConfigureOptions<AzureEventHubsTransportOptions>, AzureEventHubsPostConfigureOptions>();

// register the transport
builder.RegisterTransport<AzureEventHubsTransport, AzureEventHubsTransportOptions>();
builder.AddTransport<AzureEventHubsTransport, AzureEventHubsTransportOptions>();

return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static EventBusBuilder AddAzureQueueStorageTransport(this EventBusBuilder
});

// register the transport
builder.RegisterTransport<AzureQueueStorageTransport, AzureQueueStorageTransportOptions>();
builder.AddTransport<AzureQueueStorageTransport, AzureQueueStorageTransportOptions>();

return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static EventBusBuilder AddAzureServiceBusTransport(this EventBusBuilder b
});

// register the transport
builder.RegisterTransport<AzureServiceBusTransport, AzureServiceBusTransportOptions>();
builder.AddTransport<AzureServiceBusTransport, AzureServiceBusTransportOptions>();

return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static EventBusBuilder AddKafkaTransport(this EventBusBuilder builder, Ac
});

// register the transport
builder.RegisterTransport<KafkaTransport, KafkaTransportOptions>();
builder.AddTransport<KafkaTransport, KafkaTransportOptions>();

return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static EventBusBuilder AddRabbitMqTransport(this EventBusBuilder builder,
services.AddSingleton<IPostConfigureOptions<RabbitMqTransportOptions>, RabbitMqPostConfigureOptions>();

// register the transport
builder.RegisterTransport<RabbitMqTransport, RabbitMqTransportOptions>();
builder.AddTransport<RabbitMqTransport, RabbitMqTransportOptions>();

return builder;
}
Expand Down
9 changes: 6 additions & 3 deletions src/Tingle.EventBus/DependencyInjection/EventBusBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public EventBusBuilder(IServiceCollection services)
{
Services = services ?? throw new ArgumentNullException(nameof(services));

Services.TryAddEnumerable(
ServiceDescriptor.Singleton<IPostConfigureOptions<EventBusOptions>, EventBusPostConfigureOptions>());
Services.AddSingleton<IPostConfigureOptions<EventBusOptions>, EventBusPostConfigureOptions>();
}

/// <summary>
Expand All @@ -39,6 +38,8 @@ public EventBusBuilder(IServiceCollection services)
/// <returns></returns>
public EventBusBuilder Configure(Action<EventBusOptions> configure)
{
if (configure is null) throw new ArgumentNullException(nameof(configure));

Services.Configure(configure);
return this;
}
Expand All @@ -49,7 +50,7 @@ public EventBusBuilder Configure(Action<EventBusOptions> configure)
/// <typeparam name="TTransport"></typeparam>
/// <typeparam name="TOptions"></typeparam>
/// <returns></returns>
public EventBusBuilder RegisterTransport<TTransport, TOptions>()
public EventBusBuilder AddTransport<TTransport, TOptions>()
where TTransport : class, IEventBusTransport
where TOptions : EventBusTransportOptionsBase
{
Expand Down Expand Up @@ -233,6 +234,8 @@ public EventBusBuilder ConfigureEvent<TEvent>(Action<EventRegistration> configur

internal static string GetTransportName(Type type)
{
if (type is null) throw new ArgumentNullException(nameof(type));

// Ensure the type implements IEventBusTransport
if (!(typeof(IEventBusTransport).IsAssignableFrom(type)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static EventBusBuilder AddInMemoryTransport(this EventBusBuilder builder,
services.AddSingleton<SequenceNumberGenerator>();

// register the transport
builder.RegisterTransport<InMemoryTransport, InMemoryTransportOptions>();
builder.AddTransport<InMemoryTransport, InMemoryTransportOptions>();

return builder;
}
Expand Down

0 comments on commit 966d3e9

Please sign in to comment.