Skip to content
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

Update aggregate repository #62

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "main" ]

env:
PACKAGE_VERSION: 0.1.3
PACKAGE_VERSION: 0.1.4

jobs:

Expand Down
20 changes: 20 additions & 0 deletions CloudFabric.EventSourcing.Domain/AggregateRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@
return true;
}

public async Task UpsertItem<TItem>(string id, string partitionKey, TItem item, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(id))
{
throw new ArgumentNullException(nameof(id));

Check warning on line 106 in CloudFabric.EventSourcing.Domain/AggregateRepository.cs

View check run for this annotation

Codecov / codecov/patch

CloudFabric.EventSourcing.Domain/AggregateRepository.cs#L106

Added line #L106 was not covered by tests
}

await _eventStore.UpsertItem(id, partitionKey, item, cancellationToken);
}

Check warning on line 110 in CloudFabric.EventSourcing.Domain/AggregateRepository.cs

View check run for this annotation

Codecov / codecov/patch

CloudFabric.EventSourcing.Domain/AggregateRepository.cs#L109-L110

Added lines #L109 - L110 were not covered by tests

public async Task<TItem?> LoadItem<TItem>(string id, string partitionKey, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(id))
{
throw new ArgumentNullException(nameof(id));

Check warning on line 116 in CloudFabric.EventSourcing.Domain/AggregateRepository.cs

View check run for this annotation

Codecov / codecov/patch

CloudFabric.EventSourcing.Domain/AggregateRepository.cs#L116

Added line #L116 was not covered by tests
}

return await _eventStore.LoadItem<TItem?>(id, partitionKey, cancellationToken);
}

Check warning on line 120 in CloudFabric.EventSourcing.Domain/AggregateRepository.cs

View check run for this annotation

Codecov / codecov/patch

CloudFabric.EventSourcing.Domain/AggregateRepository.cs#L119-L120

Added lines #L119 - L120 were not covered by tests

/// <summary>
/// We should not be able to hard delete events within implementation, but for some development issues we do need to be able to do so.
/// Use this method carefuly and at your own risk. When something went terribly wrong, there is no way to recover deleted data.
Expand Down
12 changes: 12 additions & 0 deletions CloudFabric.EventSourcing.Domain/IAggregateRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@ public interface IAggregateRepository<T> where T : AggregateBase

Task<bool> SaveAsync(EventUserInfo eventUserInfo, T aggregate, CancellationToken cancellationToken = default);

/// <summary>
/// Provides additional posisbility to store objects within AggregateRepository.
/// </summary>
/// <typeparam name="TItem">Generic type parameter</typeparam>
Task UpsertItem<TItem>(string id, string partitionKey, TItem item, CancellationToken cancellationToken = default);

/// <summary>
/// Load saved object.
/// </summary>
/// <typeparam name="TItem">Generic type parameter</typeparam>
Task<TItem?> LoadItem<TItem>(string id, string partitionKey, CancellationToken cancellationToken = default);

Task<bool> HardDeleteAsync(Guid id, string partitionKey, CancellationToken cancellationToken = default);
}
Loading