Package com.faunadb.common
Class Connection
- java.lang.Object
-
- com.faunadb.common.Connection
-
public class Connection extends Object
The HTTP Connection adapter for FaunaDB drivers.Relies on
HttpClientfor the underlying implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConnection.BuilderA builder for theConnectioninstance.static classConnection.JvmDriver
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Connection.Builderbuilder()Returns a newConnection.Builderinstance.CompletableFuture<HttpResponse<String>>get(String path, Map<String,List<String>> params, Optional<Duration> queryTimeout)Issues aGETrequest with the provided request parameters.CompletableFuture<HttpResponse<String>>get(String path, Optional<Duration> queryTimeout)Issues aGETrequest with no parameters.longgetLastTxnTime()Get the freshest timestamp reported to this client.ConnectionnewSessionConnection(String authToken)Creates a newConnectionsharing its underneath I/O resources.CompletableFuture<HttpResponse<String>>patch(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)Issues aPATCHrequest with the provided JSON request body.CompletableFuture<HttpResponse<Flow.Publisher<List<ByteBuffer>>>>performStreamRequest(String httpMethod, String path, com.fasterxml.jackson.databind.JsonNode body, Map<String,List<String>> params)CompletableFuture<HttpResponse<String>>post(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)Issues aPOSTrequest with the provided JSON request body.CompletableFuture<HttpResponse<String>>put(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)Issues aPUTrequest with the provided JSON request body.CompletableFuture<HttpResponse<Flow.Publisher<List<ByteBuffer>>>>streamRequest(HttpRequest req)voidsyncLastTxnTime(long newTxnTime)Sync the freshest timestamp seen by this client.
-
-
-
Method Detail
-
builder
public static Connection.Builder builder()
Returns a newConnection.Builderinstance.- Returns:
- a new
Connection.Builder
-
newSessionConnection
public Connection newSessionConnection(String authToken)
Creates a newConnectionsharing its underneath I/O resources. Queries submitted to a session connection will be authenticated with the token provided.- Parameters:
authToken- the token or key to be used to authenticate requests to the newConnection- Returns:
- a new
Connection
-
getLastTxnTime
public long getLastTxnTime()
Get the freshest timestamp reported to this client.
-
syncLastTxnTime
public void syncLastTxnTime(long newTxnTime)
Sync the freshest timestamp seen by this client. This has no effect if more stale than the currently stored timestamp. WARNING: This should be used only when coordinating timestamps across multiple clients. Moving the timestamp arbitrarily forward into the future will cause transactions to stall.
-
get
public CompletableFuture<HttpResponse<String>> get(String path, Optional<Duration> queryTimeout)
Issues aGETrequest with no parameters.- Parameters:
path- the relative path of the resource.queryTimeout- the query timeout for the current request.- Returns:
- a
CompletableFuturecontaining the HTTP Response.
-
get
public CompletableFuture<HttpResponse<String>> get(String path, Map<String,List<String>> params, Optional<Duration> queryTimeout)
Issues aGETrequest with the provided request parameters.- Parameters:
path- the relative path of the resource.params- a map containing the request parameters.queryTimeout- the query timeout for the current request.- Returns:
- a
CompletableFuturecontaining the HTTP response.
-
post
public CompletableFuture<HttpResponse<String>> post(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)
Issues aPOSTrequest with the provided JSON request body.- Parameters:
path- the relative path of the resource.body- the JSON tree that will be serialized into the request body.queryTimeout- the query timeout for the current request.- Returns:
- a
CompletableFuturecontaining the HTTP response.
-
put
public CompletableFuture<HttpResponse<String>> put(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)
Issues aPUTrequest with the provided JSON request body.- Parameters:
path- the relative path of the resource.body- the JSON tree that will be serialized into the request body.queryTimeout- the query timeout for the current request.- Returns:
- a
CompletableFuturecontaining the HTTP response.
-
patch
public CompletableFuture<HttpResponse<String>> patch(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)
Issues aPATCHrequest with the provided JSON request body.- Parameters:
path- the relative path of the resource.body- the JSON tree that will be serialized into the request body.queryTimeout- the query timeout for the current request.- Returns:
- a
CompletableFuturecontaining the HTTP response.
-
streamRequest
public CompletableFuture<HttpResponse<Flow.Publisher<List<ByteBuffer>>>> streamRequest(HttpRequest req)
-
performStreamRequest
public CompletableFuture<HttpResponse<Flow.Publisher<List<ByteBuffer>>>> performStreamRequest(String httpMethod, String path, com.fasterxml.jackson.databind.JsonNode body, Map<String,List<String>> params)
-
-