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:
parent
6682b7f60f
commit
36fa18cae7
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue