The asynchronous driver (see MongoConnection).
import scala.concurrent.Future
import reactivemongo.api.{ AsyncDriver, MongoConnection }
val driver = AsyncDriver()
val connection: Future[MongoConnection] =
driver.connect("mongodb://node:27017")
Attributes
- classLoader
a classloader used to load the actor system
- config
a custom configuration (otherwise the default options are used)
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
Closes this driver (and all its connections and resources). Will wait until the timeout for proper closing of connections before forcing hard shutdown.
Closes this driver (and all its connections and resources). Will wait until the timeout for proper closing of connections before forcing hard shutdown.
import scala.concurrent.ExecutionContext
def afterClose(drv: reactivemongo.api.AsyncDriver)(
implicit ec: ExecutionContext) = drv.close().andThen {
case res => println("Close 'Try' result: " + res)
}
Attributes
Creates a new MongoConnection.
Creates a new MongoConnection.
Attributes
- nodes
The list of node names (e.g. ''node1.foo.com:27017''); Port is optional (27017 is used by default)
import scala.concurrent.Future import reactivemongo.api.MongoConnection val driver = reactivemongo.api.AsyncDriver() val con: Future[MongoConnection] = driver.connect( Seq("node1:27017", "node2:27017", "node3:27017")) // with default options and automatic name
Creates a new MongoConnection.
Creates a new MongoConnection.
Attributes
- nodes
The list of node names (e.g. ''node1.foo.com:27017''); Port is optional (27017 is used by default)
- options
the options for the new connection pool
import scala.concurrent.Future import reactivemongo.api.{ MongoConnection, MongoConnectionOptions } val driver = reactivemongo.api.AsyncDriver() val con: Future[MongoConnection] = driver.connect( nodes = Seq("node1:27017", "node2:27017", "node3:27017"), options = MongoConnectionOptions.default.copy(nbChannelsPerNode = 10)) // with automatic name
Creates a new MongoConnection.
Creates a new MongoConnection.
Attributes
- name
the name for the connection pool
import scala.concurrent.Future import reactivemongo.api.{ MongoConnection, MongoConnectionOptions } val driver = reactivemongo.api.AsyncDriver() val con: Future[MongoConnection] = driver.connect( nodes = Seq("node1:27017", "node2:27017", "node3:27017"), options = MongoConnectionOptions.default.copy(nbChannelsPerNode = 10), name = "ConnectionName")
- nodes
The list of node names (e.g. ''node1.foo.com:27017''); Port is optional (27017 is used by default)
- options
the options for the new connection pool
Creates a new MongoConnection from URI.
Creates a new MongoConnection from URI.
Attributes
- uriStrict
the strict URI, that will be parsed by reactivemongo.api.MongoConnection.fromString
import scala.concurrent.Future import reactivemongo.api.MongoConnection val driver = reactivemongo.api.AsyncDriver() val con: Future[MongoConnection] = driver.connect("mongodb://user123:passwd123@host1:27018,host2:27019,host3:27020/somedb?foo=bar&authenticationMechanism=scram-sha1") // with automatic name
Creates a new MongoConnection from URI.
Creates a new MongoConnection from URI.
Attributes
- name
the name for the connection pool
import scala.concurrent.Future import reactivemongo.api.MongoConnection val driver = reactivemongo.api.AsyncDriver() val con: Future[MongoConnection] = driver.connect("mongodb://user123:passwd123@host1:27018,host2:27019,host3:27020/somedb?foo=bar&authenticationMechanism=scram-sha1", name = Some("ConnectionName"))
- uriStrict
the strict URI, that will be parsed by reactivemongo.api.MongoConnection.fromString
Creates a new MongoConnection from URI.
Creates a new MongoConnection from URI.
Attributes
- name
the name for the connection pool
import scala.concurrent.Future import reactivemongo.api.MongoConnection, MongoConnection.ParsedURI val driver = reactivemongo.api.AsyncDriver() def con(uri: ParsedURI): Future[MongoConnection] = driver.connect(uri, name = Some("ConnectionName"))
- parsedURI
The URI parsed by reactivemongo.api.MongoConnection.fromString
Creates a new MongoConnection from URI.
Creates a new MongoConnection from URI.
Attributes
- name
the name for the connection pool
- parsedURI
The URI parsed by reactivemongo.api.MongoConnection.fromString
- strictMode
the flag to indicate whether the given URI must be a strict one (no ignored/invalid options)
import scala.concurrent.Future import reactivemongo.api.MongoConnection, MongoConnection.ParsedURI val driver = reactivemongo.api.AsyncDriver() def con(uri: ParsedURI): Future[MongoConnection] = driver.connect(uri, name = Some("ConnectionName"))
Creates a new MongoConnection from URI.
Creates a new MongoConnection from URI.
Attributes
- parsedURI
the URI parsed by reactivemongo.api.MongoConnection.fromString
import scala.concurrent.Future import reactivemongo.api.MongoConnection, MongoConnection.ParsedURI val driver = reactivemongo.api.AsyncDriver() def con(uri: ParsedURI): Future[MongoConnection] = driver.connect(uri) // with automatic name