Class Credential
java.lang.Object
com.couchbase.columnar.client.java.Credential
Create an instance like this:
Credential.of(username, password)
For advanced use cases involving dynamic credentials, see
ofDynamic(Supplier)
.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Credential
Returns a new instance that holds the given username and password.static Credential
ofDynamic
(Supplier<Credential> supplier) Returns a new instance of a dynamic credential that invokes the given supplier the supplier every time a credential is required.
-
Method Details
-
of
Returns a new instance that holds the given username and password. -
ofDynamic
Returns a new instance of a dynamic credential that invokes the given supplier the supplier every time a credential is required.This enables updating a credential without having to restart your application.
IMPORTANT: The supplier's
get()
method must not do blocking IO or other expensive operations. It is called from async contexts, where blocking can starve important SDK resources like async event loops.Instead of blocking inside the supplier, consider having the supplier return a value from a volatile field. Then keep the field up to date by scheduling a recurring task that reads new credentials from an external source and stores them in the volatile field.
-