Retries, LB, Failover and support of GraphQL
Configuration changes
Astra allows now multiple regions. the configuration evolved to be able to cope with them. The secureConnectBundle will now be a folder, the others regions will be retrieved dynamically.
AstraClient client = AstraClient.builder()
.withDatabaseId("ABC") // Unique identifier for your instance
.withDatabaseRegion("DEF") // Cloud Provider region picked for you instance
.withKeyspace("KS") // (optional) Set your keyspace
.withToken("token")
.withClientId("clientId") // Will be used as your username
.withClientSecret("clientSecret") // Will be used as your password
.build();
Retries and request Configuration
At Stargate level, you can now specified a fined-grained configuration for the HTTP Client.
StargateClient.builder()
//...
.withHttpRetryConfig(new RetryConfigBuilder()
.retryOnAnyException()
.withDelayBetweenTries(Duration.ofMillis(100))
.withExponentialBackoff()
withMaxNumberOfTries(3)
.build())
.withHttpRequestConfig(RequestConfig.custom()
.setCookieSpec(StandardCookieSpec.STRICT)
.setExpectContinueEnabled(true)
.setConnectionRequestTimeout(Timeout.ofSeconds(2))
.setConnectTimeout(Timeout.ofSeconds(2))
.setTargetPreferredAuthSchemes(Arrays.asList(StandardAuthScheme.NTLM, StandardAuthScheme.DIGEST))
.build()
);
GraphQL Support
You can now query dynamically the GraphQL endpoints.
// Given a stargateClient
CqlSchemaClient cqlSchemaClient = stargateClient.apiGraphQL().cqlSchema();
cqlSchemaClient.queryListKeyspaces());
Spring Data-Ish Repositories with Document API
// Random bean
Person johnConnor = new Person("John", "Connor", 20, new Address("Syberdyn", 75000));
// Create the repository providing `namespace` name and `collection` name
StargateDocumentRepository<Person> personRepo = new StargateDocumentRepository<Person>(
stargateClient.apiDocument().namespace("namespaceA").collection("collectionB"),
Person.class);
// insert
String docId = personRepo.insert(johnConnor);
// Let's the magic happens
Stream<Document<Person>> records = personRepository.findAll();