/// <summary> /// Waits until a saga exists with the specified correlationId /// </summary> /// <param name="correlationId"></param> /// <param name="timeout"></param> /// <returns></returns> public async Task <Guid?> Exists(Guid correlationId, TimeSpan?timeout = default) { if (_querySagaRepository == null) { throw new InvalidOperationException("The repository does not support Query operations"); } var giveUpAt = DateTime.Now + (timeout ?? TestTimeout); var query = new SagaQuery <TSaga>(x => x.CorrelationId == correlationId); while (DateTime.Now < giveUpAt) { var saga = (await _querySagaRepository.Find(query).ConfigureAwait(false)).FirstOrDefault(); if (saga != Guid.Empty) { return(saga); } await Task.Delay(10).ConfigureAwait(false); } return(default);
public static Task <IEnumerable <Guid> > Where <TSaga>(this IQuerySagaRepository <TSaga> source, Expression <Func <TSaga, bool> > filter) where TSaga : class, ISaga { return(source.Find(new SagaQuery <TSaga>(filter))); }