Skip to content

Commit

Permalink
Package upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
eben-roux committed Aug 5, 2024
1 parent 7624ea2 commit 1ac3a37
Show file tree
Hide file tree
Showing 17 changed files with 933 additions and 3 deletions.
56 changes: 56 additions & 0 deletions Shuttle.Recall.Logging/AddProjectionPipelineLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Shuttle.Core.Contract;
using Shuttle.Core.Pipelines;
using System.Threading.Tasks;
using System.Threading;
using System;

namespace Shuttle.Recall.Logging
{
public class AddProjectionPipelineLogger : IHostedService
{
private readonly Type _pipelineType = typeof(AddProjectionPipeline);
private readonly ILogger<AddProjectionPipelineLogger> _logger;
private readonly IPipelineFactory _pipelineFactory;
private readonly IRecallLoggingConfiguration _recallLoggingConfiguration;

public AddProjectionPipelineLogger(ILogger<AddProjectionPipelineLogger> logger, IRecallLoggingConfiguration recallLoggingConfiguration, IPipelineFactory pipelineFactory)
{
_logger = Guard.AgainstNull(logger, nameof(logger));
_recallLoggingConfiguration = Guard.AgainstNull(recallLoggingConfiguration, nameof(recallLoggingConfiguration));
_pipelineFactory = Guard.AgainstNull(pipelineFactory, nameof(pipelineFactory));

if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType))
{
_pipelineFactory.PipelineCreated += OnPipelineCreated;
}
}

public async Task StartAsync(CancellationToken cancellationToken)
{
await Task.CompletedTask;
}

private void OnPipelineCreated(object sender, PipelineEventArgs args)
{
if (args.Pipeline.GetType() != _pipelineType)
{
return;
}

args.Pipeline.RegisterObserver(new AddProjectionPipelineObserver(_logger, _recallLoggingConfiguration));
}

public async Task StopAsync(CancellationToken cancellationToken)
{
if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType))
{
_pipelineFactory.PipelineCreated -= OnPipelineCreated;

}

await Task.CompletedTask;
}
}
}
46 changes: 46 additions & 0 deletions Shuttle.Recall.Logging/AddProjectionPipelineObserver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Shuttle.Core.Pipelines;

namespace Shuttle.Recall.Logging
{
public class AddProjectionPipelineObserver : PipelineObserver<AddProjectionPipelineLogger>,
IPipelineObserver<OnBeforeAddProjection>,
IPipelineObserver<OnAddProjection>,
IPipelineObserver<OnAfterAddProjection>
{
public AddProjectionPipelineObserver(ILogger<AddProjectionPipelineLogger> logger, IRecallLoggingConfiguration recallLoggingConfiguration) : base(logger, recallLoggingConfiguration)
{
}

public void Execute(OnBeforeAddProjection pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnBeforeAddProjection pipelineEvent)
{
await Trace(pipelineEvent);
}

public void Execute(OnAddProjection pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnAddProjection pipelineEvent)
{
await Trace(pipelineEvent);
}

public void Execute(OnAfterAddProjection pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnAfterAddProjection pipelineEvent)
{
await Trace(pipelineEvent);
}
}
}
56 changes: 56 additions & 0 deletions Shuttle.Recall.Logging/AssembleEventEnvelopePipelineLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Shuttle.Core.Contract;
using Shuttle.Core.Pipelines;
using System.Threading.Tasks;
using System.Threading;
using System;

namespace Shuttle.Recall.Logging
{
public class AssembleEventEnvelopePipelineLogger : IHostedService
{
private readonly Type _pipelineType = typeof(AssembleEventEnvelopePipeline);
private readonly ILogger<AssembleEventEnvelopePipelineLogger> _logger;
private readonly IPipelineFactory _pipelineFactory;
private readonly IRecallLoggingConfiguration _recallLoggingConfiguration;

public AssembleEventEnvelopePipelineLogger(ILogger<AssembleEventEnvelopePipelineLogger> logger, IRecallLoggingConfiguration recallLoggingConfiguration, IPipelineFactory pipelineFactory)
{
_logger = Guard.AgainstNull(logger, nameof(logger));
_recallLoggingConfiguration = Guard.AgainstNull(recallLoggingConfiguration, nameof(recallLoggingConfiguration));
_pipelineFactory = Guard.AgainstNull(pipelineFactory, nameof(pipelineFactory));

if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType))
{
_pipelineFactory.PipelineCreated += OnPipelineCreated;
}
}

public async Task StartAsync(CancellationToken cancellationToken)
{
await Task.CompletedTask;
}

private void OnPipelineCreated(object sender, PipelineEventArgs args)
{
if (args.Pipeline.GetType() != _pipelineType)
{
return;
}

args.Pipeline.RegisterObserver(new AssembleEventEnvelopePipelineObserver(_logger, _recallLoggingConfiguration));
}

public async Task StopAsync(CancellationToken cancellationToken)
{
if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType))
{
_pipelineFactory.PipelineCreated -= OnPipelineCreated;

}

await Task.CompletedTask;
}
}
}
101 changes: 101 additions & 0 deletions Shuttle.Recall.Logging/AssembleEventEnvelopePipelineObserver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Shuttle.Core.Pipelines;

namespace Shuttle.Recall.Logging
{
public class AssembleEventEnvelopePipelineObserver : PipelineObserver<AssembleEventEnvelopePipelineLogger>,
IPipelineObserver<OnAssembleEventEnvelope>,
IPipelineObserver<OnAfterAssembleEventEnvelope>,
IPipelineObserver<OnSerializeEvent>,
IPipelineObserver<OnAfterSerializeEvent>,
IPipelineObserver<OnEncryptEvent>,
IPipelineObserver<OnAfterEncryptEvent>,
IPipelineObserver<OnCompressEvent>,
IPipelineObserver<OnAfterCompressEvent>
{
public AssembleEventEnvelopePipelineObserver(ILogger<AssembleEventEnvelopePipelineLogger> logger, IRecallLoggingConfiguration recallLoggingConfiguration) : base(logger, recallLoggingConfiguration)
{
}

public void Execute(OnAssembleEventEnvelope pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnAssembleEventEnvelope pipelineEvent)
{
await Trace(pipelineEvent);
}

public void Execute(OnAfterAssembleEventEnvelope pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnAfterAssembleEventEnvelope pipelineEvent)
{
await Trace(pipelineEvent);
}

public void Execute(OnSerializeEvent pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnSerializeEvent pipelineEvent)
{
await Trace(pipelineEvent);
}

public void Execute(OnAfterSerializeEvent pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnAfterSerializeEvent pipelineEvent)
{
await Trace(pipelineEvent);
}

public void Execute(OnEncryptEvent pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnEncryptEvent pipelineEvent)
{
await Trace(pipelineEvent);
}

public void Execute(OnAfterEncryptEvent pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnAfterEncryptEvent pipelineEvent)
{
await Trace(pipelineEvent);
}

public void Execute(OnCompressEvent pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnCompressEvent pipelineEvent)
{
await Trace(pipelineEvent);
}

public void Execute(OnAfterCompressEvent pipelineEvent)
{
Trace(pipelineEvent).GetAwaiter().GetResult();
}

public async Task ExecuteAsync(OnAfterCompressEvent pipelineEvent)
{
await Trace(pipelineEvent);
}
}
}
1 change: 0 additions & 1 deletion Shuttle.Recall.Logging/EventProcessingPipelineLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public EventProcessingPipelineLogger(ILogger<EventProcessingPipelineLogger> logg
if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType))
{
_pipelineFactory.PipelineCreated += OnPipelineCreated;

}
}

Expand Down
56 changes: 56 additions & 0 deletions Shuttle.Recall.Logging/EventProcessorStartupPipelineLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Shuttle.Core.Contract;
using Shuttle.Core.Pipelines;
using System.Threading.Tasks;
using System.Threading;
using System;

namespace Shuttle.Recall.Logging
{
public class EventProcessorStartupPipelineLogger : IHostedService
{
private readonly Type _pipelineType = typeof(EventProcessorStartupPipeline);
private readonly ILogger<EventProcessorStartupPipelineLogger> _logger;
private readonly IPipelineFactory _pipelineFactory;
private readonly IRecallLoggingConfiguration _recallLoggingConfiguration;

public EventProcessorStartupPipelineLogger(ILogger<EventProcessorStartupPipelineLogger> logger, IRecallLoggingConfiguration recallLoggingConfiguration, IPipelineFactory pipelineFactory)
{
_logger = Guard.AgainstNull(logger, nameof(logger));
_recallLoggingConfiguration = Guard.AgainstNull(recallLoggingConfiguration, nameof(recallLoggingConfiguration));
_pipelineFactory = Guard.AgainstNull(pipelineFactory, nameof(pipelineFactory));

if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType))
{
_pipelineFactory.PipelineCreated += OnPipelineCreated;
}
}

public async Task StartAsync(CancellationToken cancellationToken)
{
await Task.CompletedTask;
}

private void OnPipelineCreated(object sender, PipelineEventArgs args)
{
if (args.Pipeline.GetType() != _pipelineType)
{
return;
}

args.Pipeline.RegisterObserver(new EventProcessorStartupPipelineObserver(_logger, _recallLoggingConfiguration));
}

public async Task StopAsync(CancellationToken cancellationToken)
{
if (_recallLoggingConfiguration.ShouldLogPipelineType(_pipelineType))
{
_pipelineFactory.PipelineCreated -= OnPipelineCreated;

}

await Task.CompletedTask;
}
}
}
Loading

0 comments on commit 1ac3a37

Please sign in to comment.