-
Notifications
You must be signed in to change notification settings - Fork 15
Feature/new cli library #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduced new Config-Objects to abstract away cli-arguments to config transformation. Will also be needed for YAML/JSON configuration in the future
Also fixed a bug - the Object types are the actual key which should be translated into Key-Values later
No need for RunActionTest anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we have some small behaviour changes, should we document them in the readme?
|
||
class ReporterManager { | ||
|
||
private List<ReporterOptions> reporterOptionsList; | ||
private List<Throwable> reporterGatherErrors; | ||
private ExecutorService executorService; | ||
|
||
ReporterManager(List<String> reporterParams ) { | ||
initReporterOptionsList(reporterParams); | ||
ReporterManager(ReporterConfig[] reporterConfigs ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me share with you my point. I prefere to use simple constructors and use factory methods for all necessary operation neede to call the constructor. I don't like calling functions from a constructor as it doesn't allow making fields final and I personnaly like final fields. Do you mind making a small refactoring of this place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like
public static ReporterManager create( ReporterConfig[] reporterConfigs ) { ...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes with all necessary stuff populating arrays done there and then call a simple private constructor.
@@ -108,38 +112,58 @@ void startReporterGatherers(ExecutorService executorService, final DataSource da | |||
|
|||
this.executorService = executorService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move it to the constructor? don't we know the executor service at construction time? That way we could make it also final.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ExecutorService is added later, but maybe this can be refactored, too.
I'd like to postpone this to the restructuring of ReporterManager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok!
} | ||
|
||
option.getReporterObj().getOutputBuffer().printAvailable(conn, printStreams); | ||
} catch (SQLException | FileNotFoundException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we fall on any exception but only on these two?
@@ -14,15 +14,15 @@ | |||
|
|||
private Reporter reporterObj = null; | |||
|
|||
public ReporterOptions(String reporterName, String outputFileName, boolean outputToScreen) { | |||
public ReporterOptions(String reporterName, String outputFileName ) { | |||
setReporterName(reporterName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two fields should be final and set directly, not through the setters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And check what fields can also be final, seems like first three.
int returnCode = 0; | ||
try { | ||
|
||
final List<Reporter> reporterList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move it to initialization.
dbout for example |
I don't like the current state of |
ok! |
private ReporterOptions getDefaultReporterOption() { | ||
return new ReporterOptions(CoreReporters.UT_DOCUMENTATION_REPORTER.name()); | ||
} | ||
|
||
private void abortGathering(Throwable e) { | ||
addGatherError(e); | ||
executorService.shutdownNow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized this might be an issue. We get the executorService from the outside but we shut it down here. I'm concerned if the caller is ok with its executorService been shut down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually the purpose: If one Reporter Consumption fails, it should abort all the other Reporter threads.
But that's one of the things I want to do differently/more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets abort tasks then, not the excutor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will make that more clear in a restructured version
Requested changes will come in a later iteration |
Introduces Picocli as new command-line library
Structures the options and organizes them into immutable configuration objects which can better be computed and shared.
Fixes #143