add things (there are bugs, this is unstable!)
This commit is contained in:
@@ -55,6 +55,13 @@
|
|||||||
<version>2.12.1</version>
|
<version>2.12.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/io.quarkus/quarkus-agroal -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-agroal</artifactId>
|
||||||
|
<version>3.19.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -61,6 +61,14 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getJdbcUrl() {
|
||||||
|
return String.format("%s://%s:%s/%s",
|
||||||
|
config.getProperty("db.protocol"),
|
||||||
|
config.getProperty("db.host"),
|
||||||
|
config.getProperty("db.port"),
|
||||||
|
config.getProperty("db.name"));
|
||||||
|
}
|
||||||
|
|
||||||
public String getStringProperty(String key) {
|
public String getStringProperty(String key) {
|
||||||
return config.getProperty(key);
|
return config.getProperty(key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,22 +18,27 @@ import net.miarma.contaminus.common.Constants;
|
|||||||
|
|
||||||
public class DatabaseManager {
|
public class DatabaseManager {
|
||||||
private final JDBCPool pool;
|
private final JDBCPool pool;
|
||||||
|
private final Vertx vertx = Vertx.vertx();
|
||||||
|
|
||||||
public DatabaseManager(Vertx vertx) {
|
private static DatabaseManager instance;
|
||||||
|
|
||||||
|
public static DatabaseManager getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new DatabaseManager();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DatabaseManager() {
|
||||||
ConfigManager config = ConfigManager.getInstance();
|
ConfigManager config = ConfigManager.getInstance();
|
||||||
|
pool = JDBCPool.pool(vertx,
|
||||||
JDBCConnectOptions jdbcOptions = new JDBCConnectOptions()
|
new JDBCConnectOptions()
|
||||||
.setJdbcUrl(config.getStringProperty("db.protocol") + "//" +
|
.setJdbcUrl(config.getJdbcUrl())
|
||||||
config.getStringProperty("db.host") + ":" +
|
.setUser(config.getStringProperty("db.user"))
|
||||||
config.getStringProperty("db.port") + "/" +
|
.setPassword(config.getStringProperty("db.pwd")),
|
||||||
config.getStringProperty("db.name"))
|
new PoolOptions()
|
||||||
.setUser(config.getStringProperty("db.user"))
|
.setMaxSize(5)
|
||||||
.setPassword(config.getStringProperty("db.pwd"));
|
);
|
||||||
|
|
||||||
PoolOptions poolOptions = new PoolOptions()
|
|
||||||
.setMaxSize(Integer.parseInt(config.getStringProperty("db.poolSize")));
|
|
||||||
|
|
||||||
pool = JDBCPool.pool(vertx, jdbcOptions, poolOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Future<RowSet<Row>> testConnection() {
|
public Future<RowSet<Row>> testConnection() {
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ public class DataLayerAPIVerticle extends AbstractVerticle {
|
|||||||
public void start(Promise<Void> startPromise) {
|
public void start(Promise<Void> startPromise) {
|
||||||
Constants.LOGGER.info("📡 Iniciando DataLayerAPIVerticle...");
|
Constants.LOGGER.info("📡 Iniciando DataLayerAPIVerticle...");
|
||||||
|
|
||||||
configManager = ConfigManager.getInstance();
|
configManager = ConfigManager.getInstance();
|
||||||
gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
|
gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
|
||||||
dbManager = new DatabaseManager(vertx);
|
dbManager = DatabaseManager.getInstance();
|
||||||
|
|
||||||
Router router = Router.router(vertx);
|
Router router = Router.router(vertx);
|
||||||
Set<HttpMethod> allowedMethods = new HashSet<>(
|
Set<HttpMethod> allowedMethods = new HashSet<>(
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class LogicLayerAPIVerticle extends AbstractVerticle {
|
|||||||
|
|
||||||
configManager = ConfigManager.getInstance();
|
configManager = ConfigManager.getInstance();
|
||||||
gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
|
gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
|
||||||
dbManager = new DatabaseManager(vertx);
|
dbManager = DatabaseManager.getInstance();
|
||||||
|
|
||||||
Router router = Router.router(vertx);
|
Router router = Router.router(vertx);
|
||||||
Set<HttpMethod> allowedMethods = new HashSet<>(
|
Set<HttpMethod> allowedMethods = new HashSet<>(
|
||||||
|
|||||||
@@ -8,32 +8,18 @@ import io.vertx.core.ThreadingModel;
|
|||||||
public class MainVerticle extends AbstractVerticle {
|
public class MainVerticle extends AbstractVerticle {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Promise<Void> startPromise) {
|
public void start(Promise<Void> startPromise) {
|
||||||
final DeploymentOptions options = new DeploymentOptions();
|
final DeploymentOptions options = new DeploymentOptions();
|
||||||
options.setThreadingModel(ThreadingModel.WORKER);
|
options.setThreadingModel(ThreadingModel.WORKER);
|
||||||
|
|
||||||
String enabledVerticles = System.getProperty("vertx.options", "");
|
getVertx().deployVerticle(new DataLayerAPIVerticle(), options);
|
||||||
|
//getVertx().deployVerticle(new LogicLayerAPIVerticle(), options);
|
||||||
if (enabledVerticles.contains("data")) {
|
//getVertx().deployVerticle(new HttpServerVerticle());
|
||||||
getVertx().deployVerticle(new DataLayerAPIVerticle(), options);
|
|
||||||
}
|
|
||||||
if (enabledVerticles.contains("business")) {
|
|
||||||
getVertx().deployVerticle(new LogicLayerAPIVerticle(), options);
|
|
||||||
}
|
|
||||||
if (enabledVerticles.contains("web")) {
|
|
||||||
getVertx().deployVerticle(new HttpServerVerticle());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop(Promise<Void> stopPromise) throws Exception {
|
public void stop(Promise<Void> stopPromise) throws Exception {
|
||||||
getVertx().deploymentIDs()
|
getVertx().deploymentIDs()
|
||||||
.forEach(v -> getVertx().undeploy(v));
|
.forEach(v -> getVertx().undeploy(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.setProperty("vertx.options", String.join(",", args));
|
|
||||||
io.vertx.core.Launcher.executeCommand("run", MainVerticle.class.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,9 @@ public class SystemUtil {
|
|||||||
static ConfigManager configManager = ConfigManager.getInstance();
|
static ConfigManager configManager = ConfigManager.getInstance();
|
||||||
static String host = configManager.getStringProperty("inet.host");
|
static String host = configManager.getStringProperty("inet.host");
|
||||||
static String origin = configManager.getStringProperty("inet.origin");
|
static String origin = configManager.getStringProperty("inet.origin");
|
||||||
static int dataApiPort = configManager.getIntProperty("data-api.port");
|
static int dataApiPort = 8081;
|
||||||
static int logicApiPort = configManager.getIntProperty("logic-api.port");
|
static int logicApiPort = 8082;
|
||||||
static int webserverPort = configManager.getIntProperty("webserver.port");
|
static int webserverPort = 8080;
|
||||||
|
|
||||||
public static String getHost() {
|
public static String getHost() {
|
||||||
return host;
|
return host;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
"appConfig": {
|
"appConfig": {
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
"BASE_URL": "http://localhost:8081/api/v1",
|
"BASE_URL": "http://localhost:3001/api/v1",
|
||||||
"GET_GROUPS": "/groups",
|
"GET_GROUPS": "/groups",
|
||||||
"GET_GROUP_BY_ID": "/groups/{0}",
|
"GET_GROUP_BY_ID": "/groups/{0}",
|
||||||
"GET_GROUP_DEVICES": "/groups/{0}/devices",
|
"GET_GROUP_DEVICES": "/groups/{0}/devices",
|
||||||
|
|||||||
Reference in New Issue
Block a user