i am new to mongo scala driver i am trying to add connection pool size when initiating a mongo instance i am doing it something like this
val settings: MongoClientSettings = MongoClientSettings.builder()
.applyToConnectionPoolSettings(ConnectionPoolSettings.Builder.maxSize(100))
.applyToClusterSettings(b => b.hosts(List(new ServerAddress("localhost")).asJava).description("Local Server"))
.build()
val mongoClient: MongoClient = MongoClient(settings)
value maxSize is not a member of object com.mongodb.connection.ConnectionPoolSettings.Builder [error].applyToConnectionPoolSettings(ConnectionPoolSettings.Builder.maxSize(100))
what is the right way to do this?
It is a small typo on your code
ConnectionPoolSettings.Builder.maxSize(100)
should be
ConnectionPoolSettings.builder().maxSize(100)
The code with the Block would look like this:
val settings: MongoClientSettings = MongoClientSettings.builder()
.applyToConnectionPoolSettings((t: ConnectionPoolSettings.Builder) => t.applySettings(ConnectionPoolSettings.builder().maxSize(100).build()))
.applyToClusterSettings(b => b.hosts(List(new ServerAddress("localhost")).asJava).description("Local Server"))
.build()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.