コード例 #1
0
        public void LogFunctionStarted(FunctionInstanceSnapshot snapshot)
        {
            // Which operation to run depends on whether or not the entity currently exists in the "queued" status.
            IConcurrentDocument <FunctionInstanceSnapshot> existingSnapshot = _store.Read(GetId(snapshot));

            bool previouslyQueued;

            // If the existing entity doesn't contain a StartTime, it must be in the "queued" status.
            if (existingSnapshot != null && existingSnapshot.Document != null && !existingSnapshot.Document.StartTime.HasValue)
            {
                previouslyQueued = true;
            }
            else
            {
                previouslyQueued = false;
            }

            if (!previouslyQueued)
            {
                LogFunctionStartedWhenNotPreviouslyQueued(snapshot);
            }
            else
            {
                LogFunctionStartedWhenPreviouslyQueued(snapshot, existingSnapshot.ETag);
            }
        }
コード例 #2
0
        public FunctionStatistics Lookup(string functionId)
        {
            IConcurrentDocument <FunctionStatistics> result = _store.Read(functionId);

            if (result == null)
            {
                return(null);
            }

            return(result.Document);
        }
コード例 #3
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));
            }
        }