Litote / kmongo

[deprecated] KMongo - a Kotlin toolkit for Mongo
https://litote.org/kmongo/
Apache License 2.0
781 stars 74 forks source link

Connection timeout #348

Closed NoakPalander closed 2 years ago

NoakPalander commented 2 years ago

How do you specify a max time a connection can be waiting for, this is essentially a one liner with the pymongo driver (serverSelectionTimeoutMS) but seems to be outright impossible with kmongo, and there isnt anything mentioning how to properly set the setting in the documentation.

zigzago commented 2 years ago

With KMongo, you can use a raw connection string or the ConnectionString class - both methods are supported https://litote.org/kmongo/dokka/kmongo/org.litote.kmongo/-k-mongo/index.html

HTH

NoakPalander commented 2 years ago

It would appear that I was using the wrong property, this currently works

val settings = MongoClientSettings.builder()
            .applyToClusterSettings {
                it.serverSelectionTimeout(10, TimeUnit.SECONDS)
            }
            .build()

val client = KMongo.createClient(settings).coroutine