Skip to content

Commit 87edca1

Browse files
committed
Refactor interfaces and update Azure Key Vault options
Refactored various interfaces for better readability and added XML documentation comments. Introduced new generic interface `IDeletionAudited<TUser>`. Removed unnecessary `using` statements. Updated `OutboxProcessor` and `ServiceBusMessageDispatcher` for readability. Made several properties nullable in different classes and interfaces. Added new properties to `AzureKeyVaultOptions` and introduced `ExtensionsCertificates` for Azure Key Vault integration. Removed `UseAzureKeyVault` method from `Extensions` class.
1 parent 6e091e5 commit 87edca1

File tree

21 files changed

+215
-64
lines changed

21 files changed

+215
-64
lines changed
Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
namespace Genocs.Core.Domain.Entities.Auditing
1+
namespace Genocs.Core.Domain.Entities.Auditing;
2+
3+
/// <summary>
4+
/// This interface is implemented by entities which wanted to store deletion information (who and when deleted).
5+
/// </summary>
6+
public interface IDeletionAudited : IHasDeletionTime
27
{
38
/// <summary>
4-
/// This interface is implemented by entities which wanted to store deletion information (who and when deleted).
9+
/// Which user deleted this entity.
510
/// </summary>
6-
public interface IDeletionAudited : IHasDeletionTime
7-
{
8-
/// <summary>
9-
/// Which user deleted this entity?
10-
/// </summary>
11-
long? DeleterUserId { get; set; }
12-
}
11+
long? DeleterUserId { get; set; }
12+
}
1313

14+
/// <summary>
15+
/// Adds navigation properties to <see cref="IDeletionAudited"/> interface for user.
16+
/// </summary>
17+
/// <typeparam name="TUser">Type of the user.</typeparam>
18+
public interface IDeletionAudited<TUser> : IDeletionAudited
19+
where TUser : IEntity<long>
20+
{
1421
/// <summary>
15-
/// Adds navigation properties to <see cref="IDeletionAudited"/> interface for user.
22+
/// Reference to the deleter user of this entity.
1623
/// </summary>
17-
/// <typeparam name="TUser">Type of the user</typeparam>
18-
public interface IDeletionAudited<TUser> : IDeletionAudited
19-
where TUser : IEntity<long>
20-
{
21-
/// <summary>
22-
/// Reference to the deleter user of this entity.
23-
/// </summary>
24-
TUser DeleterUser { get; set; }
25-
}
24+
TUser DeleterUser { get; set; }
2625
}

src/Genocs.Core/Domain/Entities/Auditing/IFullAudited.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ namespace Genocs.Core.Domain.Entities.Auditing;
55
/// </summary>
66
public interface IFullAudited : IAudited, IDeletionAudited
77
{
8-
98
}
109

1110
/// <summary>
1211
/// Adds navigation properties to <see cref="IFullAudited"/> interface for user.
1312
/// </summary>
14-
/// <typeparam name="TUser">Type of the user</typeparam>
13+
/// <typeparam name="TUser">Type of the user.</typeparam>
1514
public interface IFullAudited<TUser> : IAudited<TUser>, IFullAudited, IDeletionAudited<TUser>
1615
where TUser : IEntity<long>
1716
{

src/Genocs.Core/Domain/Entities/Auditing/IHasCreationTime.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
namespace Genocs.Core.Domain.Entities.Auditing;
22

3-
using System;
4-
53
/// <summary>
64
/// An entity can implement this interface if <see cref="CreationTime"/> of this entity must be stored.
75
/// <see cref="CreationTime"/> is automatically set when saving <see cref="Entity"/> to database.
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
namespace Genocs.MessageBrokers.Outbox;
22

33
/// <summary>
4-
/// The Message Outbox interface definition
4+
/// The Message Outbox interface definition.
55
/// </summary>
66
public interface IMessageOutbox
77
{
88
bool Enabled { get; }
99

1010
Task HandleAsync(string messageId, Func<Task> handler);
1111

12-
Task SendAsync<T>(T message,
13-
string? originatedMessageId = null,
14-
string? messageId = null,
15-
string? correlationId = null,
16-
string? spanContext = null,
17-
object? messageContext = null,
18-
IDictionary<string, object>? headers = null) where T : class;
12+
Task SendAsync<T>(
13+
T message,
14+
string? originatedMessageId = null,
15+
string? messageId = null,
16+
string? correlationId = null,
17+
string? spanContext = null,
18+
object? messageContext = null,
19+
IDictionary<string, object>? headers = null)
20+
where T : class;
1921
}

src/Genocs.MessageBrokers.Outbox/Processors/OutboxProcessor.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ internal sealed class OutboxProcessor : IHostedService
1616
private readonly OutboxType _type;
1717
private Timer _timer;
1818

19-
public OutboxProcessor(IServiceProvider serviceProvider, IBusPublisher publisher, OutboxOptions options,
20-
ILogger<OutboxProcessor> logger)
19+
public OutboxProcessor(
20+
IServiceProvider serviceProvider,
21+
IBusPublisher publisher,
22+
OutboxOptions options,
23+
ILogger<OutboxProcessor> logger)
2124
{
2225
if (options.Enabled && options.IntervalMilliseconds <= 0)
2326
{
@@ -79,7 +82,7 @@ private void SendOutboxMessages(object state)
7982

8083
private async Task SendOutboxMessagesAsync()
8184
{
82-
var jobId = Guid.NewGuid().ToString("N");
85+
string jobId = Guid.NewGuid().ToString("N");
8386
_logger.LogTrace($"Started processing outbox messages... [job id: '{jobId}']");
8487
var stopwatch = new Stopwatch();
8588
stopwatch.Start();

src/Genocs.MessageBrokers.RabbitMQ/Extensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public static class Extensions
3030
/// </summary>
3131
/// <param name="builder">The builder.</param>
3232
/// <param name="sectionName">the default section name.</param>
33-
/// <param name="plugins"></param>
34-
/// <param name="connectionFactoryConfigurator"></param>
35-
/// <param name="serializer"></param>
33+
/// <param name="plugins">The plugin action method.</param>
34+
/// <param name="connectionFactoryConfigurator">The configurator.</param>
35+
/// <param name="serializer">The serializer.</param>
3636
/// <returns></returns>
3737
/// <exception cref="ArgumentException">Raised when configuration is incorrect.</exception>
3838
public static IGenocsBuilder AddRabbitMq(

src/Genocs.MessageBrokers.RabbitMQ/FailedMessage.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ namespace Genocs.MessageBrokers.RabbitMQ;
44

55
public class FailedMessage
66
{
7-
public object Message { get; }
7+
public object? Message { get; }
88
public bool ShouldRetry { get; }
99

1010
[Description("This will only work if 'deadLetter' is enabled in RabbitMQ options." +
1111
"For more information, see https://www.rabbitmq.com/dlx.html")]
1212
public bool MoveToDeadLetter { get; }
1313

14-
public FailedMessage(bool shouldRetry = true, bool moveToDeadLetter = true) : this(null, shouldRetry,
15-
moveToDeadLetter)
14+
public FailedMessage(bool shouldRetry = true, bool moveToDeadLetter = true)
15+
: this(null, shouldRetry, moveToDeadLetter)
1616
{
1717
}
1818

19-
public FailedMessage(object message, bool shouldRetry = true, bool moveToDeadLetter = true)
19+
public FailedMessage(object? message, bool shouldRetry = true, bool moveToDeadLetter = true)
2020
{
2121
Message = message;
2222
ShouldRetry = shouldRetry;

src/Genocs.MessageBrokers.RabbitMQ/IConventionsBuilder.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
31
namespace Genocs.MessageBrokers.RabbitMQ;
42

53
public interface IConventionsBuilder

src/Genocs.MessageBrokers.RabbitMQ/Subscribers/MessageSubscriber.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ internal class MessageSubscriber : IMessageSubscriber
44
{
55
public MessageSubscriberAction Action { get; }
66
public Type Type { get; }
7-
public Func<IServiceProvider, object, object, Task> Handle { get; }
7+
public Func<IServiceProvider, object, object, Task>? Handle { get; }
88

9-
private MessageSubscriber(MessageSubscriberAction action, Type type,
10-
Func<IServiceProvider, object, object, Task> handle = null)
9+
private MessageSubscriber(
10+
MessageSubscriberAction action,
11+
Type type,
12+
Func<IServiceProvider, object, object, Task>? handle = null)
1113
{
1214
Action = action;
1315
Type = type;

src/Genocs.MessageBrokers/CQRS/Dispatchers/ServiceBusMessageDispatcher.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ public ServiceBusMessageDispatcher(IBusPublisher busPublisher, ICorrelationConte
1414
_accessor = accessor;
1515
}
1616

17-
public Task SendAsync<T>(T command, CancellationToken cancellationToken = default) where T : class, ICommand
17+
public Task SendAsync<T>(T command, CancellationToken cancellationToken = default)
18+
where T : class, ICommand
1819
=> _busPublisher.SendAsync(command, _accessor.CorrelationContext);
1920

20-
public Task PublishAsync<T>(T @event, CancellationToken cancellationToken = default) where T : class, IEvent
21+
public Task PublishAsync<T>(T @event, CancellationToken cancellationToken = default)
22+
where T : class, IEvent
2123
=> _busPublisher.PublishAsync(@event, _accessor.CorrelationContext);
2224
}

0 commit comments

Comments
 (0)