paulirwin commented on code in PR #1170:
URL: https://github.com/apache/lucenenet/pull/1170#discussion_r2300870470


##########
src/dotnet/Lucene.Net.Replicator.AspNetCore/AspNetCoreReplicationResponse.cs:
##########
@@ -68,5 +70,21 @@ public void Flush()
         {
             response.Body.Flush();
         }
+
+        /// <summary>
+        /// Flushes the response to the underlying response stream 
asynchronously.
+        /// </summary>
+        /// <param name="cancellationToken">Optional cancellation 
token.</param>
+        /// <returns>A task representing the asynchronous operation.</returns>
+        /// <remarks>
+        /// This simply calls <see 
cref="Stream.FlushAsync(CancellationToken)"/> on the <see 
cref="HttpResponse.Body"/>.
+        /// </remarks>
+        public async Task FlushAsync(CancellationToken cancellationToken = 
default)
+        {
+            if (response.Body.CanWrite)

Review Comment:
   This check does not exist in Flush above, I wonder if this is needed?



##########
src/Lucene.Net.Replicator/Http/ReplicationService.cs:
##########
@@ -188,5 +191,70 @@ public virtual void Perform(IReplicationRequest request, 
IReplicationResponse re
                 response.Flush();
             }
         }
+
+        /// <summary>
+        /// Executes the replication task asynchronously.
+        /// </summary>
+        /// <param name="request">The replication request containing action 
and parameters.</param>
+        /// <param name="response">The replication response used to send data 
back to the client.</param>
+        /// <param name="cancellationToken">A <see cref="CancellationToken"/> 
to observe while performing the replication.</param>
+        /// <exception cref="InvalidOperationException">Thrown when required 
parameters are missing or invalid.</exception>
+        public virtual async Task PerformAsync(IReplicationRequest request, 
IReplicationResponse response, CancellationToken cancellationToken = default)

Review Comment:
   This is largely duplicated code from above. I wonder if there's a way to 
reuse some code between the methods?



##########
src/Lucene.Net.Replicator/SessionToken.cs:
##########
@@ -112,6 +114,33 @@ public void Serialize(DataOutputStream writer)
             }
         }
 
+        /// <summary>
+        /// Asynchronously serialize the token data for communication between 
server and client.
+        /// </summary>
+        /// <param name="output">The <see cref="Stream"/> to write the token 
data to.</param>
+        /// <param name="cancellationToken">A cancellation token to observe 
while waiting for the flush to complete.</param>
+        /// <returns>A task representing the asynchronous operation.</returns>
+        public async Task SerializeAsync(Stream output, CancellationToken 
cancellationToken = default)
+        {
+            using var writer = new DataOutputStream(output);
+            writer.WriteUTF(Id);

Review Comment:
   I think we might need async overloads of these `WriteUTF` and `WriteInt32` 
methods too (and any similar others on that type, might as well). Otherwise, 
these calls might throw if synchronous IO is not enabled, right?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to