Ejemplo n.º 1
0
        /// <summary>
        /// Build a FunctionId from the host and function name.
        /// </summary>
        /// <param name="hostName"></param>
        /// <param name="functionName"></param>
        /// <returns></returns>
        public static FunctionId Build(string hostName, string functionName)
        {
            var value = string.Concat(
                TableScheme.NormalizeFunctionName(hostName),
                "-",
                TableScheme.NormalizeFunctionName(functionName));

            return(Parse(value));
        }
Ejemplo n.º 2
0
        public Task <string[]> GetFunctionNamesAsync()
        {
            var query   = TableScheme.GetRowsInPartition <FunctionDefinitionEntity>(TableScheme.FuncDefIndexPK);
            var results = _instanceTable.ExecuteQuery(query).ToArray();

            var functionNames = Array.ConvertAll(results, entity => entity.GetFunctionName());

            return(Task.FromResult(functionNames));
        }
 public static FunctionDefinitionEntity New(string functionName)
 {
     return(new FunctionDefinitionEntity
     {
         PartitionKey = PartitionKeyFormat,
         RowKey = string.Format(CultureInfo.InvariantCulture, RowKeyFormat, TableScheme.NormalizeFunctionName(functionName)),
         OriginalName = functionName
     });
 }
        public static TableQuery <TimelineAggregateEntity> GetQuery(string functionName, DateTime start, DateTime end)
        {
            string rowKeyStart = RowKeyTimeIntervalPrefix(functionName, start);
            string rowKeyEnd   = RowKeyTimeIntervalPrefix(functionName, end);

            var rangeQuery = TableScheme.GetRowsInRange <TimelineAggregateEntity>(
                PartitionKeyFormat,
                rowKeyStart, rowKeyEnd);

            return(rangeQuery);
        }
Ejemplo n.º 5
0
        public static TableQuery <ContainerActiveEntity> GetQuery(DateTime start, DateTime end)
        {
            string rowKeyStart = RowKeyTimeIntervalPrefix(start);
            string rowKeyEnd   = RowKeyTimeIntervalPrefix(end);

            var rangeQuery = TableScheme.GetRowsInRange <ContainerActiveEntity>(
                TableScheme.ContainerActivePK,
                rowKeyStart, rowKeyEnd);

            return(rangeQuery);
        }
Ejemplo n.º 6
0
        private async Task <IFunctionDefinition[]> GetFunctionDefinitionsHelperAsync(CloudTable table, string hostName)
        {
            TableQuery <FunctionDefinitionEntity> query;

            if (hostName == null)
            {
                query = TableScheme.GetRowsInPartition <FunctionDefinitionEntity>(TableScheme.FuncDefIndexPK);
            }
            else
            {
                query = TableScheme.GetRowsWithPrefixAsync <FunctionDefinitionEntity>(TableScheme.FuncDefIndexPK,
                                                                                      TableScheme.NormalizeFunctionName(hostName));
            }
            var results = await table.SafeExecuteQueryAsync(query);

            return(results);
        }
Ejemplo n.º 7
0
        public async Task <Segment <IFunctionDefinition> > GetFunctionDefinitionsAsync(string continuationToken)
        {
            var query   = TableScheme.GetRowsInPartition <FunctionDefinitionEntity>(TableScheme.FuncDefIndexPK);
            var results = await _instanceTable.SafeExecuteQueryAsync(query);

            DateTime min = DateTime.MinValue;

            foreach (var entity in results)
            {
                if (entity.Timestamp > min)
                {
                    min = entity.Timestamp.DateTime;
                }
            }

            var segment = new Segment <IFunctionDefinition>(results);

            return(segment);
        }
Ejemplo n.º 8
0
        internal static TableQuery <RecentPerFuncEntity> GetRecentFunctionsQuery(
            RecentFunctionQuery queryParams
            )
        {
            string functionName = queryParams.FunctionName;
            var    start        = queryParams.Start;
            var    end          = queryParams.End;

            string rowKeyStart = RowKeyTimeStampDescendingPrefix(functionName, end);

            // add a tick to create a greater row key so that we lexically compare
            var    start2    = (start == DateTime.MinValue) ? start : start.AddTicks(-1);
            string rowKeyEnd = RowKeyTimeStampDescendingPrefix(functionName, start2);

            string partKey = PartitionKeyFormat;

            var rangeQuery = TableScheme.GetRowsInRange <RecentPerFuncEntity>(
                partKey, rowKeyStart, rowKeyEnd);

            rangeQuery.Take(queryParams.MaximumResults);
            return(rangeQuery);
        }
Ejemplo n.º 9
0
        // Salt must be deterministic.
        internal static string RowKeyTimeStampDescending(string functionName, DateTime startTime, Guid salt)
        {
            var x = (DateTime.MaxValue.Ticks - startTime.Ticks);

            // Need Salt since timestamp may not be unique
            int    salt2  = salt.GetHashCode();
            string rowKey = string.Format(CultureInfo.InvariantCulture, RowKeyFormat, TableScheme.NormalizeFunctionName(functionName), x, salt2);

            return(rowKey);
        }
Ejemplo n.º 10
0
        // No salt. This is a prefix, so we'll pick up all ranges.
        private static string RowKeyTimeStampDescendingPrefix(string functionName, DateTime startTime)
        {
            var x = (DateTime.MaxValue.Ticks - startTime.Ticks);

            string rowKey = string.Format(CultureInfo.InvariantCulture, RowKeyPrefix, TableScheme.NormalizeFunctionName(functionName), x);

            return(rowKey);
        }
        internal static string RowKeyTimeInterval(string functionId, DateTime dateTime, string hostId)
        {
            var    bucket = TimeBucket.ConvertToBucket(dateTime);
            string rowKey = string.Format(CultureInfo.InvariantCulture, RowKeyFormat, TableScheme.NormalizeFunctionName(functionId), bucket, hostId);

            return(rowKey);
        }
Ejemplo n.º 12
0
        // Time first, support range queries in a time window.
        internal static string RowKeyTimeInterval(long timeBucket, string containerName)
        {
            string rowKey = string.Format(CultureInfo.InvariantCulture, RowKeyFormat, timeBucket, TableScheme.NormalizeContainerName(containerName));

            return(rowKey);
        }