andreachild commented on code in PR #3137:
URL: https://github.com/apache/tinkerpop/pull/3137#discussion_r2157328268
##########
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/GraphManager.java:
##########
@@ -125,26 +126,48 @@ public default boolean hasAnyOpenTransactions() {
return graph.features().graph().supportsTransactions() &&
graph.tx().isOpen();
});
}
-
+
/**
* This method will be called before a script or query is processed by the
* gremlin-server.
*
* @param msg the {@link RequestMessage} received by the gremlin-server.
*/
default void beforeQueryStart(final RequestMessage msg) {
-
}
/**
* This method will be called before a script or query is processed by the
* gremlin-server.
+ * <p>
+ * This method delegates call to the {@link
#beforeQueryStart(RequestMessage)} by default, this functionality
+ * should be preserved by overriding methods if call of the former method
is still needed.
+ *
+ * @param msg the {@link RequestMessage} received by the gremlin-server.
+ * @param user User authenticated in channel processing request
+ */
+ default void beforeQueryStart(final RequestMessage msg, AuthenticatedUser
user) {
Review Comment:
In order to account for evolving lifecycle requirements it would be more
flexible for the overloaded method to accept a single query context parameter
that can be adapted to contain more information as needed in the future. This
way if more data is needed, it need only be added to the query context and no
additional overloaded method is needed.
Something like:
```
/**
* This method will be called before a script or query is processed by the
* gremlin-server.
*
* @param msg the {@link RequestMessage} received by the gremlin-server.
* @deprecated replaced by {@link #beforeQueryStart(QueryContext)}
*/
default void beforeQueryStart(final RequestMessage msg) {
beforeQueryStart(new QueryContext(msg, null));
}
default void beforeQueryStart(final QueryContext context) {
}
public static class QueryContext {
private RequestMessage msg;
private AuthenticatedUser user;
// other fields can be added in the future without breaking backwards
compatibility
public QueryContext(final RequestMessage msg, final AuthenticatedUser
user) {
this.msg = msg;
this.user = user;
}
public RequestMessage getMessage() {
return msg;
}
public AuthenticatedUser getUser() {
return user;
}
}
```
--
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]