summaryrefslogtreecommitdiff
path: root/opendc-common/src/main/kotlin/org/opendc/common/utils/ConfigParser.kt
diff options
context:
space:
mode:
authormjkwiatkowski <mati.rewa@gmail.com>2026-02-16 15:18:21 +0100
committermjkwiatkowski <mati.rewa@gmail.com>2026-02-16 15:18:21 +0100
commit2f16cb0f48eca4453e3e894b3d45a3aa09e6dcc0 (patch)
tree672d98baa2ac071f2c30de06d613254d0d8cd105 /opendc-common/src/main/kotlin/org/opendc/common/utils/ConfigParser.kt
parent86d35fcec83057e346e4982b5a6908f25342a392 (diff)
feat: opendc -> kafka -> postgresql works; added protobuf encodingHEADmaster
Diffstat (limited to 'opendc-common/src/main/kotlin/org/opendc/common/utils/ConfigParser.kt')
-rw-r--r--opendc-common/src/main/kotlin/org/opendc/common/utils/ConfigParser.kt37
1 files changed, 31 insertions, 6 deletions
diff --git a/opendc-common/src/main/kotlin/org/opendc/common/utils/ConfigParser.kt b/opendc-common/src/main/kotlin/org/opendc/common/utils/ConfigParser.kt
index cb9623bb..e6f18da5 100644
--- a/opendc-common/src/main/kotlin/org/opendc/common/utils/ConfigParser.kt
+++ b/opendc-common/src/main/kotlin/org/opendc/common/utils/ConfigParser.kt
@@ -11,32 +11,40 @@ import java.io.InputStream
import java.io.OutputStream
import java.net.Socket
import java.sql.Connection
-import java.sql.DriverManager
-import java.sql.SQLException
/**
+ * @author Mateusz
* @property name
* @property backlog the amount of connections to accept
- * @property databasePath
* @property address IPv4 address
* @property port
+ * @property postgresql Postgresql port
+ * @property username Postgresql user
+ * @property password Postgresql password
+ * @property database Postgresql database
+ * @property topic Kafka topic
+ * @property kafka Kafka port
*/
@Serializable
public data class Config(
val name: String = "",
var backlog: Int = 0,
val address: String = "",
- val port: Int = 8080,
- val postgresql: Int = 5342,
+ val port: Int = 0,
+ val postgresql: Int = 0,
val username : String = "",
val password : String = "",
- val database: String = ""
+ val database: String = "",
+ val topic : String = "",
+ val kafka: Int = 0,
){
public companion object{
public var input: InputStream? = null
public var output: OutputStream? = null
public var connection : Connection? = null
+ public var kafka : Kafka? = null
+ public var database : PostgresqlDB? = null
public var socket: Socket? = null
@@ -57,9 +65,26 @@ public data class Config(
public fun getConfigWriter() : OutputStream? {
return output
}
+
+ public fun setKafkaInstance(kafka : Kafka) {
+ this.kafka = kafka
+ }
+
+ public fun getKafkaInstance() : Kafka? {
+ return this.kafka
+ }
+
+ public fun setDB(db : PostgresqlDB){
+ this.database = db
+ }
+
+ public fun getDB() : PostgresqlDB?{
+ return this.database
+ }
}
}
/**
+ * @author Mateusz
* Reads `config.json` into Config data class.
*/
public class ConfigReader {