示例#1
0
        public override async Task ReplayMessagesAsync(IActorContext context, string persistenceId, long fromSequenceNr, long toSequenceNr, long max,
                                                       Action <IPersistentRepresentation> recoveryCallback)
        {
            Query query = new Query(_journalKind)
            {
                Filter = Filter.And(
                    Filter.HasAncestor(RootKey(persistenceId)),
                    Filter.GreaterThanOrEqual(JournalFields.SequenceNr, fromSequenceNr),
                    Filter.LessThanOrEqual(JournalFields.SequenceNr, toSequenceNr)
                    ),
                Order   = { { JournalFields.SequenceNr, PropertyOrder.Types.Direction.Ascending } }
                , Limit = max > Int32.MaxValue? (int?)null : (int)max
            };

            var results = await _db.RunQueryAsync(query).ConfigureAwait(false);

            results.Entities
            .Select(MapEntityToPersistentRepresentation)
            .ForEach(recoveryCallback);
        }
示例#2
0
        protected override async Task DeleteMessagesToAsync(string persistenceId, long toSequenceNr)
        {
            Query query = new Query(_journalKind)
            {
                Filter = Filter.And(
                    Filter.HasAncestor(RootKey(persistenceId)),
                    Filter.LessThanOrEqual(JournalFields.SequenceNr, toSequenceNr)
                    )
            };

            var results = await _db.RunQueryAsync(query).ConfigureAwait(false);

            await _db.DeleteAsync(results.Entities);

            var rootEntitySeqNr = await ReadHighestSequenceNrAsync(persistenceId, 0);

            if (rootEntitySeqNr == toSequenceNr)
            {
                await DeleteRootEntity(persistenceId).ConfigureAwait(false);
            }
        }
示例#3
0
 /// <summary>
 /// Lazily executes the given structured query in this transaction for asynchronous consumption.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Using a transaction ensures that a commit operation will fail if any of the entities returned
 /// by this query have been modified while the transaction is active. Note that modifications performed
 /// as part of this operation are not reflected in the query results.
 /// </para>
 /// <para>
 /// The results are requested lazily: no API calls will be made until the application starts
 /// iterating over the results. Iterating over the same <see cref="LazyDatastoreQuery"/> object
 /// multiple times will execute the query again, potentially returning different results.
 /// </para>
 /// </remarks>
 /// <param name="query">The query to execute. Must not be null.</param>
 /// <param name="callSettings">If not null, applies overrides to RPC calls.</param>
 /// <returns>An <see cref="AsyncLazyDatastoreQuery"/> representing the result of the query.</returns>
 public virtual AsyncLazyDatastoreQuery RunQueryLazilyAsync(Query query, CallSettings callSettings = null)
 {
     throw new NotImplementedException();
 }
示例#4
0
 /// <summary>
 /// Runs the given query eagerly in this transaction, retrieving all results in memory and indicating whether more
 /// results may be available beyond the query's limit. Use this method when your query has a limited
 /// number of results, for example to build a web application which fetches results in pages.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Using a transaction ensures that a commit operation will fail if any of the entities returned
 /// by this query have been modified while the transaction is active. Note that modifications performed
 /// as part of this operation are not reflected in the query results.
 /// </para>
 /// <para>The default implementation of this method delegates to <see cref="RunQueryLazily(Query, CallSettings)"/>
 /// and calls <see cref="LazyDatastoreQuery.GetAllResults"/> on the return value.</para>
 /// </remarks>
 /// <param name="query">The query to execute. Must not be null.</param>
 /// <param name="callSettings">If not null, applies overrides to RPC calls.</param>
 /// <returns>The complete query results.</returns>
 public virtual DatastoreQueryResults RunQuery(Query query, CallSettings callSettings = null) =>
 RunQueryLazily(query, callSettings).GetAllResults();
示例#5
0
 /// <summary>
 /// Runs the given query eagerly and asynchronously in this transaction, retrieving all results in memory
 /// and indicating whether more results may be available beyond the query's limit. Use this method when your query has a limited
 /// number of results, for example to build a web application which fetches results in pages.
 /// </summary>
 /// <remarks>
 /// <para>
 /// Using a transaction ensures that a commit operation will fail if any of the entities returned
 /// by this query have been modified while the transaction is active. Note that modifications performed
 /// as part of this operation are not reflected in the query results.
 /// </para>
 /// <para>The default implementation of this method delegates to <see cref="RunQueryLazilyAsync(Query, CallSettings)"/>
 /// and calls <see cref="AsyncLazyDatastoreQuery.GetAllResultsAsync"/> on the return value.</para>
 /// </remarks>
 /// <param name="query">The query to execute. Must not be null.</param>
 /// <param name="callSettings">If not null, applies overrides to RPC calls.</param>
 /// <returns>A task representing the asynchronous operation. The result of the task is the complete set of query results.</returns>
 public virtual Task <DatastoreQueryResults> RunQueryAsync(Query query, CallSettings callSettings = null) =>
 RunQueryLazilyAsync(query, callSettings).GetAllResultsAsync();