All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.ext.mongo.impl.config.SocketSettingsParser Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR1
Show newest version
package io.vertx.ext.mongo.impl.config;

import com.mongodb.ConnectionString;
import com.mongodb.connection.SocketSettings;
import io.vertx.core.json.JsonObject;

import static java.util.concurrent.TimeUnit.MILLISECONDS;

/**
 * @author Nick Scavelli
 */
class SocketSettingsParser {
  private final SocketSettings settings;

  public SocketSettingsParser(ConnectionString connectionString, JsonObject config) {
    SocketSettings.Builder settings = SocketSettings.builder();
    if (connectionString != null) {
      settings.applyConnectionString(connectionString);
    }

    Integer connectTimeoutMS = config.getInteger("connectTimeoutMS");
    if (connectTimeoutMS != null) {
      settings.connectTimeout(connectTimeoutMS, MILLISECONDS);
    }
    Integer socketTimeoutMS = config.getInteger("socketTimeoutMS");
    if (socketTimeoutMS != null) {
      settings.readTimeout(socketTimeoutMS, MILLISECONDS);
    }
    Integer receiveBufferSize = config.getInteger("receiveBufferSize");
    if (receiveBufferSize != null) {
      settings.receiveBufferSize(receiveBufferSize);
    }
    Integer sendBufferSize = config.getInteger("sendBufferSize");
    if (sendBufferSize != null) {
      settings.sendBufferSize(sendBufferSize);
    }

    this.settings = settings.build();
  }

  public SocketSettings settings() {
    return settings;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy