/// <summary>
 /// Current status of this instance.
 /// We specifically infer the status from the other fields rather than explicitly include status
 /// so that we don't duplicate state.
 /// </summary>
 public static FunctionInstanceStatus GetStatus(this IFunctionInstanceBaseEntry item)
 {
     if (item.IsCompleted())
     {
         if (item.IsSucceeded())
         {
             return(FunctionInstanceStatus.CompletedSuccess);
         }
         else
         {
             return(FunctionInstanceStatus.CompletedFailure);
         }
     }
     else
     {
         if (item.FunctionInstanceHeartbeatExpiry.HasValue)
         {
             var  now       = DateTime.UtcNow;
             bool isExpired = item.FunctionInstanceHeartbeatExpiry.Value < now;
             if (isExpired)
             {
                 return(FunctionInstanceStatus.Abandoned);
             }
         }
         return(FunctionInstanceStatus.Running);
     }
 }
 /// <summary>true if this function succeeded.</summary>
 public static bool IsSucceeded(this IFunctionInstanceBaseEntry item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     return(item.IsCompleted() && !item.HasError);
 }