Exemple #1
0
        public static bool TryGetFault <T>(this FutureState future, Guid id, out T fault)
            where T : class
        {
            if (future.HasFaults() && future.Faults.TryGetValue(id, out var message))
            {
                fault = message.ToObject <T>();
                return(fault != default);
            }

            fault = default;
            return(false);
        }
Exemple #2
0
        public static async Task <TFault> SetFault <T, TFault>(this FutureState future,
                                                               ConsumeEventContext <FutureState, T> context, Guid id, AsyncEventMessageFactory <FutureState, T, TFault> factory)
            where T : class
            where TFault : class
        {
            var timestamp = context.SentTime ?? DateTime.UtcNow;

            if (future.HasPending())
            {
                future.Pending?.Remove(id);
            }

            future.Faulted ??= timestamp;

            var fault = await factory(context).ConfigureAwait(false);

            future.Faults[id] = new FutureMessage <TFault>(fault);

            return(fault);
        }
Exemple #3
0
 public static T GetCommand <T>(this FutureState future)
     where T : class
 {
     return(future.Command?.ToObject <T>());
 }