Skip to content

Commit

Permalink
[update][reader][mongodbreader] Refactor connection item from list …
Browse files Browse the repository at this point in the history
…to string

Updated the `connection` field to be a string instead of a list. This change simplifies the data structure and improves readability.
  • Loading branch information
wgzhao committed Oct 9, 2024
1 parent 283f1b9 commit 8ef27e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
18 changes: 8 additions & 10 deletions docs/assets/jobs/mongoreader.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@
"reader": {
"name": "mongodbreader",
"parameter": {
"connection": [
{
"address": [
"127.0.0.1:27017"
],
"database": "tag_per_data",
"collection": "tag_data",
"authDb": "admin"
}
],
"connection": {
"address": [
"127.0.0.1:27017"
],
"database": "tag_per_data",
"collection": "tag_data",
"authDb": "admin"
},
"username": "",
"password": "",
"column": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void init()
password = EncryptUtil.decrypt(password.substring(6, password.length() - 1));
originalConfig.set(Key.PASSWORD, password);
}
Configuration connConf = Configuration.from(originalConfig.getList(CONNECTION, Object.class).get(0).toString());
Configuration connConf = originalConfig.getConfiguration(CONNECTION);
String database = connConf.getNecessaryValue(DATABASE, REQUIRED_VALUE);
String authDb = connConf.getString(KeyConstant.MONGO_AUTH_DB, database);
List<Object> addressList = connConf.getList(KeyConstant.MONGO_ADDRESS, Object.class);
Expand Down Expand Up @@ -248,7 +248,7 @@ public void init()
this.upperBound = readerSliceConfig.get(KeyConstant.UPPER_BOUND);
this.isObjectId = readerSliceConfig.getBool(KeyConstant.IS_OBJECT_ID);

Configuration connConf = Configuration.from(readerSliceConfig.getList(CONNECTION, Object.class).get(0).toString());
Configuration connConf = readerSliceConfig.getConfiguration(CONNECTION);
this.database = connConf.getString(DATABASE);
this.collection = connConf.getString(KeyConstant.MONGO_COLLECTION_NAME);
String authDb = connConf.getString(KeyConstant.MONGO_AUTH_DB, this.database);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static List<Configuration> doSplit(Configuration originalSliceConfig, int

List<Configuration> confList = new ArrayList<>();

Configuration connConf = Configuration.from(originalSliceConfig.getList(CONNECTION, Object.class).get(0).toString());
Configuration connConf = originalSliceConfig.getConfiguration(CONNECTION);
String dbName = connConf.getString(DATABASE);

String collName = connConf.getString(KeyConstant.MONGO_COLLECTION_NAME);
Expand Down

0 comments on commit 8ef27e9

Please sign in to comment.