Add AddManyAsync method to activity execution stores

Introduced a new AddManyAsync method across multiple activity execution stores to add collections of log records. This enhancement ensures consistency in handling bulk additions and aligns with existing store interfaces.
This commit is contained in:
Sipke Schoorstra 2025-02-17 11:32:34 +01:00
parent 6682b7f60f
commit 36fa18cae7
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F
6 changed files with 33 additions and 0 deletions

View file

@ -49,6 +49,13 @@ public class DapperActivityExecutionRecordStore : IActivityExecutionStore
await _store.SaveManyAsync(mappedRecords, PrimaryKeyName, cancellationToken);
}
/// <inheritdoc />
public async Task AddManyAsync(IEnumerable<ActivityExecutionRecord> records, CancellationToken cancellationToken = default)
{
var mappedRecords = records.Select(Map).ToList();
await store.AddManyAsync(mappedRecords, cancellationToken);
}
/// <inheritdoc />
public async Task<ActivityExecutionRecord?> FindAsync(ActivityExecutionRecordFilter filter, CancellationToken cancellationToken = default)
{

View file

@ -35,6 +35,9 @@ public class EFCoreActivityExecutionStore(
/// <inheritdoc />
public async Task SaveManyAsync(IEnumerable<ActivityExecutionRecord> records, CancellationToken cancellationToken = default) => await store.SaveManyAsync(records, OnSaveAsync, cancellationToken);
/// <inheritdoc />
public async Task AddManyAsync(IEnumerable<ActivityExecutionRecord> records, CancellationToken cancellationToken = default) => await store.AddManyAsync(records, OnSaveAsync, cancellationToken);
/// <inheritdoc />
[RequiresUnreferencedCode("Calls Elsa.EntityFrameworkCore.Modules.Runtime.EFCoreActivityExecutionStore.DeserializeActivityState(RuntimeElsaDbContext, ActivityExecutionRecord, CancellationToken)")]
public async Task<ActivityExecutionRecord?> FindAsync(ActivityExecutionRecordFilter filter, CancellationToken cancellationToken = default)

View file

@ -28,6 +28,12 @@ public class MongoActivityExecutionLogStore(MongoDbStore<ActivityExecutionRecord
return mongoDbStore.SaveManyAsync(records, cancellationToken);
}
/// <inheritdoc />
public Task AddManyAsync(IEnumerable<ActivityExecutionRecord> records, CancellationToken cancellationToken = default)
{
return mongoDbStore.AddManyAsync(records, cancellationToken);
}
/// <inheritdoc />
public Task<ActivityExecutionRecord?> FindAsync(ActivityExecutionRecordFilter filter, CancellationToken cancellationToken = default)
{

View file

@ -10,4 +10,9 @@ public interface ILogRecordStore<in T> where T : ILogRecord
/// If a record does not already exist, it is added to the store; if it does exist, its existing entry is updated.
/// </remarks>
Task SaveManyAsync(IEnumerable<T> records, CancellationToken cancellationToken = default);
/// <summary>
/// Adds a collection of log records to the store.
/// </summary>
Task AddManyAsync(IEnumerable<T> records, CancellationToken cancellationToken = default);
}

View file

@ -36,6 +36,13 @@ public class MemoryActivityExecutionStore : IActivityExecutionStore
return Task.CompletedTask;
}
/// <inheritdoc />
public Task AddManyAsync(IEnumerable<ActivityExecutionRecord> records, CancellationToken cancellationToken = default)
{
_store.AddMany(records, x => x.Id);
return Task.CompletedTask;
}
/// <inheritdoc />
public Task<ActivityExecutionRecord?> FindAsync(ActivityExecutionRecordFilter filter, CancellationToken cancellationToken = default)
{

View file

@ -17,6 +17,11 @@ public class NoopActivityExecutionStore : IActivityExecutionStore
return Task.CompletedTask;
}
public Task AddManyAsync(IEnumerable<ActivityExecutionRecord> records, CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
}
public Task<ActivityExecutionRecord?> FindAsync(ActivityExecutionRecordFilter filter, CancellationToken cancellationToken = default)
{
return Task.FromResult<ActivityExecutionRecord?>(null);