pratapnarra commented on code in PR #3258:
URL: https://github.com/apache/tinkerpop/pull/3258#discussion_r2487433381


##########
gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java:
##########
@@ -773,6 +773,80 @@ public Client alias(final Map<String, String> aliases) {
         }
     }
 
+    /**
+     * A {@code Client} implementation that operates in the context of a 
session. {@code ChildSessionClient} is tied to
+     * another client as a child, it borrows the connection from the parent 
client's pool for the transaction. Requests are
+     * sent to a single server, where each request is bound to the same thread 
and same connection with the same set of
+     * bindings across requests.
+     * Transaction are not automatically committed. It is up the client to 
issue commit/rollback commands.
+     */
+    public final static class SessionedChildClient extends Client {
+        private final String sessionId;
+        private final boolean manageTransactions;
+        private final boolean maintainStateAfterException;
+        private final Client parentClient;
+        private Connection borrowedConnection;
+        private boolean closed;
+
+        public SessionedChildClient(final Client parentClient, String 
sessionId) {
+            super(parentClient.cluster, parentClient.settings);
+            this.parentClient = parentClient;
+            this.sessionId = sessionId;
+            this.closed = false;
+            this.manageTransactions = parentClient.settings.getSession().map(s 
-> s.manageTransactions).orElse(false);
+            this.maintainStateAfterException = 
parentClient.settings.getSession().map(s -> 
s.maintainStateAfterException).orElse(false);
+        }
+
+        public String getSessionId() {
+            return sessionId;
+        }
+
+        @Override
+        public RequestMessage.Builder buildMessage(final 
RequestMessage.Builder builder) {
+            builder.processor("session");
+            builder.addArg(Tokens.ARGS_SESSION, sessionId);
+            builder.addArg(Tokens.ARGS_MANAGE_TRANSACTION, manageTransactions);
+            builder.addArg(Tokens.ARGS_MAINTAIN_STATE_AFTER_EXCEPTION, 
maintainStateAfterException);
+            return builder;
+        }
+
+        @Override
+        protected void initializeImplementation() {
+            // do nothing, parentClient is already initialized
+        }
+
+        @Override
+        protected synchronized Connection chooseConnection(RequestMessage msg) 
throws TimeoutException, ConnectionException {

Review Comment:
   Yes that's the overhead we are trying to reduce. I have updated the PR 
description as well.



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