builder
fun builder(configBlock: ClusterEnvironmentConfigBlock = {}): ClusterEnvironment.Builder
Content copied to clipboard
Returns a new ClusterEnvironment.Builder. If you provide an environment config DSL block, the returned builder has settings configured by the block. Otherwise the builder has default settings, which you can customize by calling methods on the builder.
Pass the returned builder to one of the Cluster.connect methods, or call build and pass the resulting ClusterEnvironment to Cluster.connectUsingSharedEnvironment. Remember: if you call build() yourself, you are responsible for shutting down the environment after disconnecting the clusters that share it.
Samples
import com.couchbase.client.core.env.NetworkResolution
import com.couchbase.client.core.env.SecurityConfig
import com.couchbase.client.core.retry.FailFastRetryStrategy
import com.couchbase.client.core.service.ServiceType
import com.couchbase.client.kotlin.Cluster
import com.couchbase.client.kotlin.codec.RawJsonTranscoder
import com.couchbase.client.kotlin.env.ClusterEnvironment
import com.couchbase.client.kotlin.env.dsl.TrustSource
import com.couchbase.client.kotlin.query.execute
import kotlinx.coroutines.runBlocking
import java.nio.file.Paths
import java.util.*
import kotlin.time.Duration.Companion.seconds
fun main() {
//sampleStart
// Create builder with default settings
val builder = ClusterEnvironment.builder()
//sampleEnd
}
import com.couchbase.client.core.env.NetworkResolution
import com.couchbase.client.core.env.SecurityConfig
import com.couchbase.client.core.retry.FailFastRetryStrategy
import com.couchbase.client.core.service.ServiceType
import com.couchbase.client.kotlin.Cluster
import com.couchbase.client.kotlin.codec.RawJsonTranscoder
import com.couchbase.client.kotlin.env.ClusterEnvironment
import com.couchbase.client.kotlin.env.dsl.TrustSource
import com.couchbase.client.kotlin.query.execute
import kotlinx.coroutines.runBlocking
import java.nio.file.Paths
import java.util.*
import kotlin.time.Duration.Companion.seconds
fun main() {
//sampleStart
// Preconfigure builder using DSL
val builder = ClusterEnvironment.builder {
retryStrategy = FailFastRetryStrategy.INSTANCE
io {
maxHttpConnections = 16
}
}
//sampleEnd
}
Parameters
config Block
an optional lambda for configuring the new builder using cluster environment config DSL.