Пример #1
0
 private void LogFunctionStartedWhenPreviouslyQueued(FunctionInstanceSnapshot snapshot, string etag)
 {
     // LogFunctionStarted and LogFunctionCompleted may run concurrently. LogFunctionQueued does not run
     // concurrently. Ensure LogFunctionStarted wins over LogFunctionQueued but loses to LogFunctionCompleted by
     // doing a Replace with ETag check that will fail if the entity has been changed.
     // LogFunctionCompleted wins by doing a Replace without an ETag check, so it will replace the
     // LogFunctionStarted (or Queued) record, if any.
     // Ignore the return value: if the ETag doesn't match, LogFunctionCompleted already ran, so there's no work
     // to do here.
     _store.TryUpdate(GetId(snapshot), etag, snapshot);
 }
Пример #2
0
        private bool TryUpdateEntity(string functionId, Action <FunctionStatistics> modifier)
        {
            IConcurrentDocument <FunctionStatistics> result = _store.Read(functionId);

            if (result == null || result.Document == null)
            {
                FunctionStatistics statistics = new FunctionStatistics();
                modifier.Invoke(statistics);
                return(_store.TryCreate(functionId, statistics));
            }
            else
            {
                FunctionStatistics statistics = result.Document;
                modifier.Invoke(statistics);
                return(_store.TryUpdate(functionId, result.ETag, statistics));
            }
        }