microsoft / spring-data-cosmosdb

Access data with Azure Cosmos DB
MIT License
94 stars 64 forks source link

How to pass Custom ConnectionPolicy to build DocumentDBConfig? #400

Closed swagulkarni closed 5 years ago

swagulkarni commented 5 years ago

Hi,

The OOTB DocumentDBConfig class has static methods to build the DBConfig but it uses the default ConnectionPolicy.

public static DocumentDBConfigBuilder builder(String uri, String key, String database) { return defaultBuilder() .uri(uri) .key(key) .database(database) .connectionPolicy(ConnectionPolicy.GetDefault()) .consistencyLevel(ConsistencyLevel.Session); }

We want the ability to write out own custom connectionPolicy while creating the DBConfig.

How can that be achieved?

saragluna commented 5 years ago

@swagulkarni you can customize your connectionPolicy as code shown below:

DocumentDBConfig dbConfig = DocumentDBConfig.builder(dbUri, dbKey, dbName).build();
dbConfig.getConnectionPolicy().setConnectionMode(ConnectionMode.DirectHttps);
dbConfig.getConnectionPolicy().setMaxPoolSize(1000);
...
swagulkarni commented 5 years ago

Thanks, thats helpful.

Incarnation-p-lee commented 5 years ago

@saragluna As some users ask for this, can we add this to our readme about this ?

saragluna commented 5 years ago

Will update the readme, close this issue.