shoc-backend/SeaHaven.DataServices/Interfaces/IWorkOrderIngestDataService.cs
Alexandre Brandizzi a32471d4c0 Serialize sync cancels and vendor uplift requests on the work order lock
The legacy ingest batch holds the per-work-order lock, taken in id order,
for every work order it may cancel until the batch commits. A vendor
uplift request now runs under the same lock. Uplift creation on both
routes refuses a work order cancelled by either lifecycle or status text,
so a request can neither slip past a cancel nor land after one.
2026-09-25 19:37:08 -03:00

26 lines
1.4 KiB
C#

using Data.SeaHavenIndustries;
namespace SeaHaven.DataServices.Interfaces
{
public interface IWorkOrderIngestDataService
{
Task<int> GetMaxWorkOrderIdAsync(CancellationToken cancellationToken);
Task<WorkOrder?> GetTrackedByExternalIdAsync(string externalWorkOrderId, CancellationToken cancellationToken);
void TrackWorkOrder(WorkOrder workOrder);
Task<Locations?> FindLocationAsync(string name, CancellationToken cancellationToken);
Task AddAndSaveLocationAsync(Locations location, CancellationToken cancellationToken);
// Stages (does not save) the sync-attributed cancellation of the work order's pending
// uplifts, each with its own audit row. See PendingUpliftCancellation.
Task<int> StageCancelPendingUpliftsAsync(int workOrderId, CancellationToken cancellationToken);
Task<IReadOnlyList<int>> GetWorkOrderIdsByExternalIdsAsync(
IReadOnlyCollection<string> externalWorkOrderIds,
CancellationToken cancellationToken);
// Runs the batch in one transaction, holding the per-work-order lock on
// lockedWorkOrderIds (see WorkOrderMutationLock) until it commits or rolls back.
Task ExecuteTransactionalAsync(
IReadOnlyCollection<int> lockedWorkOrderIds,
Func<CancellationToken, Task> work,
CancellationToken cancellationToken);
Task SaveAsync(CancellationToken cancellationToken);
}
}