Package dev.grafeo.gwp
Class GqlConnection
java.lang.Object
dev.grafeo.gwp.GqlConnection
- All Implemented Interfaces:
AutoCloseable
A connection to a GWP server.
Implements AutoCloseable for use with try-with-resources.
try (GqlConnection conn = GqlConnection.connect("localhost:50051")) {
try (GqlSession session = conn.createSession()) {
// use the session
}
}
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the underlying gRPC channel.static GqlConnectionConnect to a GWP server using an insecure (plaintext) channel.static GqlConnectionConnect to a GWP server.Perform a handshake and return a new session.
-
Method Details
-
connect
Connect to a GWP server using an insecure (plaintext) channel.- Parameters:
target- the server address (e.g. "localhost:50051")- Returns:
- a connected GqlConnection
- Throws:
GqlException- if the connection fails
-
connect
Connect to a GWP server.- Parameters:
target- the server address (e.g. "localhost:50051")useTls- true to use TLS, false for plaintext- Returns:
- a connected GqlConnection
- Throws:
GqlException- if the connection fails
-
createSession
Perform a handshake and return a new session.- Returns:
- a new GqlSession
-
close
public void close()Close the underlying gRPC channel.Initiates an orderly shutdown and waits up to 5 seconds for in-progress RPCs to complete.
- Specified by:
closein interfaceAutoCloseable
-