Skip to content

Edc improvements for HALO project #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: feature/HALO
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ namespace Softeq.NetKit.Components.EventBus.Service.Tests.Samples.Events
{
public class AccountRegisteredEvent : IntegrationEvent
{
public string UserId { get; }
public string Email { get; }

public AccountRegisteredEvent(string userId, string email)
{
UserId = userId;
Email = email;
}

public string UserId { get; }
public string Email { get; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@

using System.Threading.Tasks;
using Softeq.NetKit.Components.EventBus.Abstract;
using Softeq.NetKit.Components.EventBus.Events;
using Softeq.NetKit.Components.EventBus.Service.Tests.Samples.Events;

namespace Softeq.NetKit.Components.EventBus.Service.Tests.Samples.Handlers
{
public class AccountRegisteredEventHandler : IEventHandler<AccountRegisteredEvent>
public class AccountRegisteredEventHandler : IEventEnvelopeHandler<AccountRegisteredEvent>
{
// Inject your app service

// TODO: Need to change this action according to requirments
public async Task Handle(AccountRegisteredEvent @event)
// TODO: Need to change this action according to requirements
public Task HandleAsync(IntegrationEventEnvelope<AccountRegisteredEvent> eventEnvelope)
{
await Task.CompletedTask;
throw new System.NotImplementedException();
}
}
}
277 changes: 108 additions & 169 deletions Softeq.NetKit.Components.EventBus.Service/EventBusService.cs

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions Softeq.NetKit.Components.EventBus/Abstract/IDynamicEventHandler.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Softeq.NetKit.Components.EventBus.Abstract
{
public interface IEventBusPublisher
{
Task PublishToTopicAsync(IntegrationEvent @event, int? delayInSeconds = null);
Task PublishToQueueAsync(IntegrationEvent @event, int? delayInSeconds = null);
Task PublishToTopicAsync(IntegrationEventEnvelope eventEnvelope);
Task PublishToQueueAsync(IntegrationEventEnvelope eventEnvelope);
}
}
21 changes: 4 additions & 17 deletions Softeq.NetKit.Components.EventBus/Abstract/IEventBusSubscriber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,9 @@ namespace Softeq.NetKit.Components.EventBus.Abstract
{
public interface IEventBusSubscriber
{
void RegisterQueueListener(QueueListenerConfiguration configuration = null);

Task RegisterSubscriptionListenerAsync();

Task SubscribeAsync<TEvent, TEventHandler>()
where TEvent : IntegrationEvent
where TEventHandler : IEventHandler<TEvent>;

Task UnsubscribeAsync<TEvent, TEventHandler>()
where TEvent : IntegrationEvent
where TEventHandler : IEventHandler<TEvent>;

void SubscribeDynamic<TEventHandler>(string eventName)
where TEventHandler : IDynamicEventHandler;

void UnsubscribeDynamic<TEventHandler>(string eventName)
where TEventHandler : IDynamicEventHandler;
Task RegisterTopicEventListenerAsync();
void RegisterQueueEventListener(QueueListenerConfiguration configuration = null);
Task RegisterEventAsync<TEvent>() where TEvent : IntegrationEvent;
Task RemoveEventRegistrationAsync<TEvent>() where TEvent : IntegrationEvent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace Softeq.NetKit.Components.EventBus.Abstract
{
public interface IEventHandler<in TIntegrationEvent> where TIntegrationEvent : IntegrationEvent
public interface IEventEnvelopeHandler<TEvent> where TEvent : IntegrationEvent
{
Task Handle(TIntegrationEvent @event);
Task HandleAsync(IntegrationEventEnvelope<TEvent> eventEnvelope);
}
}
13 changes: 10 additions & 3 deletions Softeq.NetKit.Components.EventBus/EventPublishConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
// Developed by Softeq Development Corporation
// http://www.softeq.com

using System;

namespace Softeq.NetKit.Components.EventBus
{
public class EventPublishConfiguration
{
public EventPublishConfiguration(string eventPublisherId)
public EventPublishConfiguration(
string eventPublisherId,
bool sendCompletionEvent = true,
TimeSpan? eventTimeToLive = null)
{
EventPublisherId = eventPublisherId;
SendCompletionEvent = true;
SendCompletionEvent = sendCompletionEvent;
EventTimeToLive = eventTimeToLive;
}

public string EventPublisherId { get; }
public bool SendCompletionEvent { get; set; }
public bool SendCompletionEvent { get; }
public TimeSpan? EventTimeToLive { get; }
}
}
29 changes: 0 additions & 29 deletions Softeq.NetKit.Components.EventBus/EventSubscriptionInfo.cs

This file was deleted.

16 changes: 0 additions & 16 deletions Softeq.NetKit.Components.EventBus/Events/IntegrationEvent.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
// Developed by Softeq Development Corporation
// http://www.softeq.com

using System;
using Newtonsoft.Json;

namespace Softeq.NetKit.Components.EventBus.Events
{
public abstract class IntegrationEvent
{
protected IntegrationEvent()
{
Id = Guid.NewGuid();
CreationDate = DateTimeOffset.UtcNow;
}

[JsonProperty]
public Guid Id { get; private set; } //Do not remove 'private set' so compiler won't drop backing field setter
[JsonProperty]
public DateTimeOffset CreationDate { get; private set; } //Do not remove 'private set' so compiler won't drop backing field setter
public string PublisherId { get; set; }
public string CorrelationId { get; set; }
public string SessionId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Developed by Softeq Development Corporation
// http://www.softeq.com

using System;

namespace Softeq.NetKit.Components.EventBus.Events
{
public sealed class IntegrationEventEnvelope
{
public IntegrationEventEnvelope(
IntegrationEvent @event,
string publisherId,
string sequenceId = null,
string correlationId = null)
: this(Guid.NewGuid(), @event, publisherId, sequenceId, correlationId)
{
}

private IntegrationEventEnvelope(
Guid id,
IntegrationEvent @event,
string publisherId,
string sequenceId = null,
string correlationId = null)
{
Id = id;
Event = @event ?? throw new ArgumentNullException(nameof(@event));
PublisherId = publisherId ?? throw new ArgumentNullException(nameof(publisherId));
Created = DateTimeOffset.UtcNow;
SequenceId = sequenceId;
CorrelationId = correlationId;
}

public Guid Id { get; private set; }
public DateTimeOffset Created { get; private set; }
public string PublisherId { get; private set; }
public string SequenceId { get; private set; }
public string CorrelationId { get; private set; }
public IntegrationEvent Event { get; private set; }
public bool IsSequential => !string.IsNullOrEmpty(SequenceId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Developed by Softeq Development Corporation
// http://www.softeq.com

using Newtonsoft.Json;
using System;

namespace Softeq.NetKit.Components.EventBus.Events
{
public class IntegrationEventEnvelope<TEvent> where TEvent : IntegrationEvent
{
[JsonConstructor]
private IntegrationEventEnvelope(
Guid id,
DateTimeOffset created,
string publisherId,
string sequenceId,
string correlationId,
TEvent @event)
{
Id = id;
Created = created;
PublisherId = publisherId;
SequenceId = sequenceId;
CorrelationId = correlationId;
Event = @event;
}

public IntegrationEventEnvelope(IntegrationEventEnvelope eventEnvelope)
{
if (eventEnvelope == null)
{
throw new ArgumentNullException(nameof(eventEnvelope));
}

Event = eventEnvelope.Event as TEvent ?? throw new ArgumentException(nameof(eventEnvelope.Event));
Id = eventEnvelope.Id;
Created = eventEnvelope.Created;
PublisherId = eventEnvelope.PublisherId;
SequenceId = eventEnvelope.SequenceId;
CorrelationId = eventEnvelope.CorrelationId;
}

public Guid Id { get; private set; }
public DateTimeOffset Created { get; private set; }
public string PublisherId { get; private set; }
public string SequenceId { get; private set; }
public string CorrelationId { get; private set; }
public TEvent Event { get; }
}
}
Loading