ivandika3 commented on code in PR #1448:
URL: https://github.com/apache/ratis/pull/1448#discussion_r4100201531


##########
ratis-server-api/src/main/java/org/apache/ratis/server/RaftServer.java:
##########
@@ -142,6 +146,33 @@ default RaftGroup getGroup() {
     /** @return the {@link StateMachine} for this division. */
     StateMachine getStateMachine();
 
+    /**
+     * Execute a local read-only query after applying the configured
+     * {@link RaftServerConfigKeys.Read.Option} consistency checks.
+     *
+     * <p>This API is intended for embedded users that already have a local
+     * server division and want to avoid serializing application read requests
+     * and responses through {@link org.apache.ratis.protocol.Message}. Remote
+     * clients should continue to use
+     * {@link 
org.apache.ratis.client.api.AsyncApi#sendReadOnly(org.apache.ratis.protocol.Message)}.
+     */
+    default <T> CompletableFuture<T> 
readOnlyAsync(Supplier<CompletableFuture<T>> query) throws IOException {
+      return readOnlyAsync(ClientId.randomId(), 
ReadRequestTypeProto.getDefaultInstance(), query);
+    }
+
+    /**
+     * Execute a local read-only query after applying the configured
+     * {@link RaftServerConfigKeys.Read.Option} consistency checks.
+     *
+     * <p>The {@code clientId} and {@code readRequestType} identify the read
+     * semantics.  In particular, callers requesting read-after-write
+     * consistency must use the same client ID as their prior writes.
+     */
+    default <T> CompletableFuture<T> readOnlyAsync(ClientId clientId, 
ReadRequestTypeProto readRequestType,
+        Supplier<CompletableFuture<T>> query) throws IOException {

Review Comment:
   Changing this to `Message` would require some logic to circumvent the 
`Message` request and response bytestring conversion, like the suggested 
`OmReadOzoneMessage` in RATIS-2509. Using `Supplier` should remove the need for 
this workaround and IMO should be more flexible.
   
   What do you think?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to