From 7802ac75d08fb0c84852c130629c9713666d7f8b Mon Sep 17 00:00:00 2001 From: Nick Larew Date: Wed, 7 Feb 2024 16:46:13 -0500 Subject: [PATCH] Scala - Faq --- .../faq/econnresetWithClientConnect-example.scala | 5 +++++ code-examples/scala/faq/maxTimeMS-example.scala | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 code-examples/scala/faq/econnresetWithClientConnect-example.scala create mode 100644 code-examples/scala/faq/maxTimeMS-example.scala diff --git a/code-examples/scala/faq/econnresetWithClientConnect-example.scala b/code-examples/scala/faq/econnresetWithClientConnect-example.scala new file mode 100644 index 0000000..8f467b2 --- /dev/null +++ b/code-examples/scala/faq/econnresetWithClientConnect-example.scala @@ -0,0 +1,5 @@ +import org.mongodb.scala._ + +val mongoClient: MongoClient = MongoClient("mongodb://localhost:27017/test?maxPoolSize=5000") + +mongoClient.listDatabaseNames().results() diff --git a/code-examples/scala/faq/maxTimeMS-example.scala b/code-examples/scala/faq/maxTimeMS-example.scala new file mode 100644 index 0000000..4534ebf --- /dev/null +++ b/code-examples/scala/faq/maxTimeMS-example.scala @@ -0,0 +1,11 @@ +import org.mongodb.scala._ +import scala.concurrent.Await +import scala.concurrent.duration._ +import org.mongodb.scala.bson._ + +val collection: MongoCollection[Document] = ... +val script: BsonJavaScript = BsonJavaScript("sleep(100) || true") + +val findObservable: FindObservable[Document] = collection.find(Filters.where(script)).maxTime(50, MILLISECONDS) + +Await.result(findObservable.toFuture(), Duration(50, "millis"))