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
HttpClient
for the underlying implementation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Connection.Builder
A builder for theConnection
instance.static class
Connection.JvmDriver
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Connection.Builder
builder()
Returns a newConnection.Builder
instance.CompletableFuture<HttpResponse<String>>
get(String path, Map<String,List<String>> params, RequestParameters requestParameters)
Issues aGET
request with the provided request parameters.CompletableFuture<HttpResponse<String>>
get(String path, Map<String,List<String>> params, Optional<Duration> queryTimeout)
Issues aGET
request with the provided request parameters.CompletableFuture<HttpResponse<String>>
get(String path, Optional<Duration> queryTimeout)
Issues aGET
request with no parameters.long
getLastTxnTime()
Get the freshest timestamp reported to this client.Connection
newSessionConnection(String authToken)
Creates a newConnection
sharing its underneath I/O resources.CompletableFuture<HttpResponse<String>>
patch(String path, com.fasterxml.jackson.databind.JsonNode body, RequestParameters requestParameters)
Issues aPATCH
request with the provided JSON request body.CompletableFuture<HttpResponse<String>>
patch(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)
Issues aPATCH
request 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, RequestParameters requestParameters)
Issues aPOST
request with the provided JSON request body.CompletableFuture<HttpResponse<String>>
post(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)
Issues aPOST
request with the provided JSON request body.CompletableFuture<HttpResponse<String>>
put(String path, com.fasterxml.jackson.databind.JsonNode body, RequestParameters requestParameters)
Issues aPUT
request with the provided JSON request body.CompletableFuture<HttpResponse<String>>
put(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)
Issues aPUT
request with the provided JSON request body.CompletableFuture<HttpResponse<Flow.Publisher<List<ByteBuffer>>>>
streamRequest(HttpRequest req)
void
syncLastTxnTime(long newTxnTime)
Sync the freshest timestamp seen by this client.
-
-
-
Method Detail
-
builder
public static Connection.Builder builder()
Returns a newConnection.Builder
instance.- Returns:
- a new
Connection.Builder
-
newSessionConnection
public Connection newSessionConnection(String authToken)
Creates a newConnection
sharing 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 aGET
request with no parameters.- Parameters:
path
- the relative path of the resource.queryTimeout
- the query timeout for the current request.- Returns:
- a
CompletableFuture
containing the HTTP Response.
-
get
public CompletableFuture<HttpResponse<String>> get(String path, Map<String,List<String>> params, Optional<Duration> queryTimeout)
Issues aGET
request 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
CompletableFuture
containing the HTTP response.
-
get
public CompletableFuture<HttpResponse<String>> get(String path, Map<String,List<String>> params, RequestParameters requestParameters)
Issues aGET
request with the provided request parameters.- Parameters:
path
- the relative path of the resource.params
- a map containing the request parameters.requestParameters
- Additional metadata to be passed along with the request.- Returns:
- a
CompletableFuture
containing the HTTP response.
-
post
public CompletableFuture<HttpResponse<String>> post(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)
Issues aPOST
request 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
CompletableFuture
containing the HTTP response.
-
post
public CompletableFuture<HttpResponse<String>> post(String path, com.fasterxml.jackson.databind.JsonNode body, RequestParameters requestParameters)
Issues aPOST
request 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.requestParameters
- Additional metadata to be passed along with the request.- Returns:
- a
CompletableFuture
containing the HTTP response.
-
put
public CompletableFuture<HttpResponse<String>> put(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)
Issues aPUT
request 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
CompletableFuture
containing the HTTP response.
-
put
public CompletableFuture<HttpResponse<String>> put(String path, com.fasterxml.jackson.databind.JsonNode body, RequestParameters requestParameters)
Issues aPUT
request 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.requestParameters
- Additional metadata to be passed along with the request.- Returns:
- a
CompletableFuture
containing the HTTP response.
-
patch
public CompletableFuture<HttpResponse<String>> patch(String path, com.fasterxml.jackson.databind.JsonNode body, Optional<Duration> queryTimeout)
Issues aPATCH
request 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
CompletableFuture
containing the HTTP response.
-
patch
public CompletableFuture<HttpResponse<String>> patch(String path, com.fasterxml.jackson.databind.JsonNode body, RequestParameters requestParameters)
Issues aPATCH
request 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.requestParameters
- Additional metadata to be passed along with the request.- Returns:
- a
CompletableFuture
containing 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)
-
-