From 0e0cde8a49ea6adc6826f36a347a19e8e8682b57 Mon Sep 17 00:00:00 2001 From: Enes Hoxha Date: Sat, 5 Apr 2025 14:00:30 +0200 Subject: [PATCH 1/2] v1/bug/103: Start Pulsar Producer when SinkOperator starts. --- src/Cortex.Streams.Pulsar/PulsarSinkOperator.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Cortex.Streams.Pulsar/PulsarSinkOperator.cs b/src/Cortex.Streams.Pulsar/PulsarSinkOperator.cs index f3fa43e..a33bf9e 100644 --- a/src/Cortex.Streams.Pulsar/PulsarSinkOperator.cs +++ b/src/Cortex.Streams.Pulsar/PulsarSinkOperator.cs @@ -28,6 +28,10 @@ public PulsarSinkOperator(string serviceUrl, string topic, ISerializer s _client = PulsarClient.Builder() .ServiceUrl(new Uri(_serviceUrl)) .Build(); + + // BUG #103 Start PulsarSink Operator when Sink is initialized + // Pulsar Producer doesnot start when the production happens, we have to start the Producer when it is initialized. + Start(); } public void Start() From b270e38ec93885a968f3d584da41b63a213ee057 Mon Sep 17 00:00:00 2001 From: Matthieu PRIEUR Date: Wed, 9 Jul 2025 15:47:46 -0400 Subject: [PATCH 2/2] Add : new option to add internal or private handlers --- .../DependencyInjection/MediatorOptions.cs | 4 +++- .../ServiceCollectionExtensions.cs | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Cortex.Mediator/DependencyInjection/MediatorOptions.cs b/src/Cortex.Mediator/DependencyInjection/MediatorOptions.cs index c724388..f8a69b3 100644 --- a/src/Cortex.Mediator/DependencyInjection/MediatorOptions.cs +++ b/src/Cortex.Mediator/DependencyInjection/MediatorOptions.cs @@ -1,4 +1,4 @@ -using Cortex.Mediator.Commands; +using Cortex.Mediator.Commands; using Cortex.Mediator.Queries; using System; using System.Collections.Generic; @@ -11,6 +11,8 @@ public class MediatorOptions internal List CommandBehaviors { get; } = new(); internal List QueryBehaviors { get; } = new(); + public bool OnlyPublicClasses { get; set; } = true; + public MediatorOptions AddCommandPipelineBehavior() where TBehavior : ICommandPipelineBehavior // Add constraint { diff --git a/src/Cortex.Mediator/DependencyInjection/ServiceCollectionExtensions.cs b/src/Cortex.Mediator/DependencyInjection/ServiceCollectionExtensions.cs index 5acf911..93dc221 100644 --- a/src/Cortex.Mediator/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Cortex.Mediator/DependencyInjection/ServiceCollectionExtensions.cs @@ -1,4 +1,4 @@ -using Cortex.Mediator.Commands; +using Cortex.Mediator.Commands; using Cortex.Mediator.Infrastructure; using Cortex.Mediator.Notifications; using Cortex.Mediator.Queries; @@ -27,7 +27,7 @@ public static IServiceCollection AddCortexMediator( services.AddValidatorsFromAssemblies(handlerAssemblyMarkerTypes.Select(t => t.Assembly)); services.AddUnitOfWork(); - RegisterHandlers(services, handlerAssemblyMarkerTypes); + RegisterHandlers(services, handlerAssemblyMarkerTypes, options); RegisterPipelineBehaviors(services, options); return services; @@ -35,28 +35,29 @@ public static IServiceCollection AddCortexMediator( private static void RegisterHandlers( IServiceCollection services, - IEnumerable assemblyMarkerTypes) + IEnumerable assemblyMarkerTypes, + MediatorOptions options) { var assemblies = assemblyMarkerTypes.Select(t => t.Assembly).ToArray(); services.Scan(scan => scan .FromAssemblies(assemblies) .AddClasses(classes => classes - .AssignableTo(typeof(ICommandHandler<>))) + .AssignableTo(typeof(ICommandHandler<>)), options.OnlyPublicClasses) .AsImplementedInterfaces() .WithScopedLifetime()); services.Scan(scan => scan .FromAssemblies(assemblies) .AddClasses(classes => classes - .AssignableTo(typeof(IQueryHandler<,>))) + .AssignableTo(typeof(IQueryHandler<,>)), options.OnlyPublicClasses) .AsImplementedInterfaces() .WithScopedLifetime()); services.Scan(scan => scan .FromAssemblies(assemblies) .AddClasses(classes => classes - .AssignableTo(typeof(INotificationHandler<>))) + .AssignableTo(typeof(INotificationHandler<>)), options.OnlyPublicClasses) .AsImplementedInterfaces() .WithScopedLifetime()); } @@ -76,7 +77,6 @@ private static void RegisterPipelineBehaviors(IServiceCollection services, Media } } - private static void AddUnitOfWork(this IServiceCollection services) { services.AddScoped(provider =>