Skip to content

Commit

Permalink
Aggregate ID made optional
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinRyazantsev committed Apr 11, 2020
1 parent 950d3d3 commit 701daf9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ public Task<Outbox> Open(string requestId, Func<Task<long>> aggregateIdFactory)
throw new InvalidOperationException("Outbox repository is not configured. To use outbox, you need to configure repository in service.AddOutbox(c => {...})");
}

public Task<Outbox> Open(string requestId)
{
throw new InvalidOperationException("Outbox repository is not configured. To use outbox, you need to configure repository in service.AddOutbox(c => {...})");
}

public Task Save(Outbox outbox, OutboxPersistingReason reason)
{
throw new InvalidOperationException("Outbox repository is not configured. To use outbox, you need to configure repository in service.AddOutbox(c => {...})");
}
}
}
}
1 change: 1 addition & 0 deletions src/Swisschain.Extensions.Idempotency/IOutboxManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Swisschain.Extensions.Idempotency
public interface IOutboxManager
{
Task<Outbox> Open(string requestId, Func<Task<long>> aggregateIdFactory);
Task<Outbox> Open(string requestId);
Task Store(Outbox outbox);
Task EnsureDispatched(Outbox outbox);
Task EnsureDispatched(Outbox outbox, IOutboxDispatcher dispatcher);
Expand Down
1 change: 1 addition & 0 deletions src/Swisschain.Extensions.Idempotency/IOutboxRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Swisschain.Extensions.Idempotency
public interface IOutboxRepository
{
Task<Outbox> Open(string requestId, Func<Task<long>> aggregateIdFactory);
Task<Outbox> Open(string requestId);
Task Save(Outbox outbox, OutboxPersistingReason reason);
}
}
4 changes: 2 additions & 2 deletions src/Swisschain.Extensions.Idempotency/Outbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public void Publish(object evt)
public static Outbox Restore(string requestId,
long aggregateId,
bool isStored,
bool isShipped,
bool isDispatched,
object response,
IEnumerable<object> commands,
IEnumerable<object> events)
{
var instance = new Outbox(requestId, aggregateId, isStored, isShipped)
var instance = new Outbox(requestId, aggregateId, isStored, isDispatched)
{
Response = response
};
Expand Down
9 changes: 7 additions & 2 deletions src/Swisschain.Extensions.Idempotency/OutboxManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ public OutboxManager(IOutboxDispatcher dispatcher,
_repository = repository;
}

public async Task<Outbox> Open(string requestId, Func<Task<long>> aggregateIdFactory)
public Task<Outbox> Open(string requestId, Func<Task<long>> aggregateIdFactory)
{
return await _repository.Open(requestId, aggregateIdFactory);
return _repository.Open(requestId, aggregateIdFactory);
}

public Task<Outbox> Open(string requestId)
{
return _repository.Open(requestId);
}

public async Task Store(Outbox outbox)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ public static IServiceCollection AddOutbox(this IServiceCollection services, Act
{
services.AddTransient<IOutboxManager, OutboxManager>();

services.AddTransient<IOutboxDispatcher, DefaultOutboxDispatcher>();
services.AddTransient<IOutboxRepository, DefaultOutboxRepository>();

if (config != null)
{
var configBuilder = new OutboxConfigurationBuilder(services);

config.Invoke(configBuilder);
}
else
{

}

return services;
}
Expand Down

0 comments on commit 701daf9

Please sign in to comment.