Refactor Java Mono/Flux webClient code - Spring Boot
Budget: $30 – $250 USD
I have the attached code that runs well, loads in parallel 2 json files, merge them and returns the result for http://localhost:8080/test :
[{"hypervRefreshMs":"9000"},{"hypervRefreshMs":"5000"}]
I wish to re-factor the code to:
A. Support varing amount of json files to load.
The ID's (3,4) should come from a List<String> , so I can add more ID's to the list and no need to change anything else in the code.
B. Know which response belongs to which json:
In the above example, I used ID's 3 and 4 (which loads config3.json and config4.json attached files), it returned :[{"hypervRefreshMs":"9000"},{"hypervRefreshMs":"5000"}]
I would like it to return:
{
"3": {"hypervRefreshMs":"5000"},
"4": {"hypervRefreshMs":"9000"}
}
And if I add "5" to the List<String>, it would return:
{
"3": {"hypervRefreshMs":"5000"},
"4": {"hypervRefreshMs":"9000"},
"5": {"hypervRefreshMs":"3000"}
}
And one last request:
C. If endpoint fails (e.g: config5.json does not exists for ID 5), have some error handling like:
{
"3": {"hypervRefreshMs":"5000"},
"4": {"hypervRefreshMs":"9000"},
"5": {"error" : true}
}
[{"hypervRefreshMs":"9000"},{"hypervRefreshMs":"5000"}]
I wish to re-factor the code to:
A. Support varing amount of json files to load.
The ID's (3,4) should come from a List<String> , so I can add more ID's to the list and no need to change anything else in the code.
B. Know which response belongs to which json:
In the above example, I used ID's 3 and 4 (which loads config3.json and config4.json attached files), it returned :[{"hypervRefreshMs":"9000"},{"hypervRefreshMs":"5000"}]
I would like it to return:
{
"3": {"hypervRefreshMs":"5000"},
"4": {"hypervRefreshMs":"9000"}
}
And if I add "5" to the List<String>, it would return:
{
"3": {"hypervRefreshMs":"5000"},
"4": {"hypervRefreshMs":"9000"},
"5": {"hypervRefreshMs":"3000"}
}
And one last request:
C. If endpoint fails (e.g: config5.json does not exists for ID 5), have some error handling like:
{
"3": {"hypervRefreshMs":"5000"},
"4": {"hypervRefreshMs":"9000"},
"5": {"error" : true}
}