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


##########
ratis-server-api/src/main/java/org/apache/ratis/server/RaftServer.java:
##########
@@ -102,6 +104,21 @@ 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(
+        CheckedSupplier<CompletableFuture<T>, IOException> query) throws 
IOException {

Review Comment:
   - Since the query method in StateMachine does not throw IOException, let's 
just use Supplier here.  It will force the StateMachine to handle IOException, 
if there is any.
   ```java
   //StateMachine
     CompletableFuture<Message> query(Message request);
   ```
   - Also, we need clientId and readRequestType to support 
read-after-write-consistency.
   ```java
       default <T> CompletableFuture<T> readOnlyAsync(ClientId clientId, 
ReadRequestTypeProto readRequestType,
           Supplier<CompletableFuture<T>> query) throws IOException {
   ```



-- 
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