ClusterEnvironmentConfigBlock

A lambda for the cluster environment configuration DSL.

Samples

// Configure TLS using DSL
val cluster = Cluster.connect("localhost", "Administrator", "password") {
    security {
        enableTls = true

        // see TrustSource for more ways to specify trusted certificates
        trust = TrustSource.trustStore(
            Paths.get("/path/to/truststore.jks"),
            "password"
        )
    }
}
// Preconfigure builder using DSL
val builder = ClusterEnvironment.builder {
    retryStrategy = FailFastRetryStrategy.INSTANCE
    io {
        maxHttpConnections = 16
    }
}
// Configure many things using DSL
val cluster = Cluster.connect("localhost", "Administrator", "password") {
    applyProfile("wan-development")

    transcoder = RawJsonTranscoder

    ioEnvironment {
        enableNativeIo = false
    }

    io {
        enableDnsSrv = false
        networkResolution = NetworkResolution.EXTERNAL
        tcpKeepAliveTime = 45.seconds

        // To see traffic, must also set "com.couchbase.io" logging category to TRACE level.
        captureTraffic(ServiceType.KV, ServiceType.QUERY)

        // Specify defaults before customizing individual breakers
        allCircuitBreakers {
            enabled = true
            volumeThreshold = 30
            errorThresholdPercentage = 20
            rollingWindow = 30.seconds
        }

        kvCircuitBreaker {
            enabled = false
        }

        queryCircuitBreaker {
            rollingWindow = 10.seconds
        }
    }

    timeout {
        kvTimeout = 3.seconds
        kvDurableTimeout = 20.seconds
        connectTimeout = 15.seconds
    }

    transactions {
        durabilityLevel = Durability.majorityAndPersistToActive()

        cleanup {
            cleanupWindow = 30.seconds
        }
    }

    orphanReporter {
        emitInterval = 20.seconds
    }
}