private string MakePartitionKey(IGrainContext context, string stateName)
        {
            string grainKey = context.GrainReference.GrainId.ToString();
            var    key      = $"{grainKey}_{this.clusterOptions.ServiceId}_{stateName}";

            return(AzureTableUtils.SanitizeTableProperty(key));
        }
        private async Task <KeyEntity> ReadKey()
        {
            var query = new TableQuery <KeyEntity>()
                        .Where(AzureTableUtils.PointQuery(this.partition, KeyEntity.RK));
            TableQuerySegment <KeyEntity> queryResult = await table.ExecuteQuerySegmentedAsync(query, null).ConfigureAwait(false);

            return(queryResult.Results.Count == 0
                ? new KeyEntity()
            {
                PartitionKey = this.partition
            }
                : queryResult.Results[0]);
        }
Esempio n. 3
0
        private async Task <List <KeyValuePair <long, StateEntity> > > ReadStates()
        {
            var query       = AzureTableUtils.RangeQuery(this.partition, StateEntity.RK_MIN, StateEntity.RK_MAX);
            var results     = new List <KeyValuePair <long, StateEntity> >();
            var queryResult = table.QueryAsync <TableEntity>(query).ConfigureAwait(false);

            await foreach (var entity in queryResult)
            {
                var state = new StateEntity(entity);
                results.Add(new KeyValuePair <long, StateEntity>(state.SequenceId, state));
            }
            ;
            return(results);
        }
Esempio n. 4
0
        private async Task <KeyEntity> ReadKey()
        {
            var queryResult = table.QueryAsync <KeyEntity>(AzureTableUtils.PointQuery(this.partition, KeyEntity.RK)).ConfigureAwait(false);

            await foreach (var result in queryResult)
            {
                return(result);
            }

            return(new KeyEntity()
            {
                PartitionKey = partition,
                RowKey = KeyEntity.RK
            });
        }
        private async Task <List <KeyValuePair <long, StateEntity> > > ReadStates()
        {
            var query = new TableQuery <StateEntity>()
                        .Where(AzureTableUtils.RangeQuery(this.partition, StateEntity.RK_MIN, StateEntity.RK_MAX));
            TableContinuationToken continuationToken = null;
            var results = new List <KeyValuePair <long, StateEntity> >();

            do
            {
                TableQuerySegment <StateEntity> queryResult = await table.ExecuteQuerySegmentedAsync(query, continuationToken).ConfigureAwait(false);

                foreach (var x in queryResult.Results)
                {
                    results.Add(new KeyValuePair <long, StateEntity>(x.SequenceId, x));
                }
                ;
                continuationToken = queryResult.ContinuationToken;
            } while (continuationToken != null);
            return(results);
        }