AsyncDriver

reactivemongo.api.AsyncDriver
See theAsyncDriver companion object
final class AsyncDriver(val config: Option[Config], val classLoader: Option[ClassLoader])

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 Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def close(timeout: FiniteDuration)(implicit ec: ExecutionContext): Future[Unit]

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
def connect(uriStrict: String, name: Option[String]): Future[MongoConnection]

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

def connect[T](parsedURI: URI[T], name: Option[String]): Future[MongoConnection]

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

def connect[T](parsedURI: URI[T], name: Option[String], strictMode: Boolean): Future[MongoConnection]

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"))
def connect[T](parsedURI: URI[T]): Future[MongoConnection]

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