bakaid commented on a change in pull request #743: Minificpp 1169 - Simplify C2 
metrics collection and reporting
URL: https://github.com/apache/nifi-minifi-cpp/pull/743#discussion_r396398966
 
 

 ##########
 File path: libminifi/src/c2/C2Agent.cpp
 ##########
 @@ -32,24 +32,34 @@
 #include "utils/file/FileUtils.h"
 #include "utils/file/FileManager.h"
 #include "utils/HTTPClient.h"
+#include "utils/GeneralUtils.h"
+#include "utils/Monitors.h"
+
 namespace org {
 namespace apache {
 namespace nifi {
 namespace minifi {
 namespace c2 {
 
-C2Agent::C2Agent(const 
std::shared_ptr<core::controller::ControllerServiceProvider> &controller, const 
std::shared_ptr<state::StateMonitor> &updateSink,
-                 const std::shared_ptr<Configure> &configuration)
+std::shared_ptr<utils::IdGenerator> C2Agent::id_generator_ = 
utils::IdGenerator::getIdGenerator();
 
 Review comment:
   I don't think this contributes to the current issue, but as we discussed 
previously, `utils::IdGenerator::getIdGenerator()` should be used whenever the 
`IdGenerator` singleton instance is required, and not assigned and stored to a 
global static variable.
   
   The whole point of `utils::IdGenerator::getIdGenerator()` is to make it a 
function static initialization, because we generally want to avoid global 
static initializations, as they can be performed at dynamic library load times, 
which, especially on Windows, significantly restricts the type of OS APIs we 
can use and can cause serious, hard-to-detect issues.
   
   This reduces the IdGenerator to global static initialization. Please 
refactor C2Agent to call the `utils::IdGenerator::getIdGenerator()` singleton 
getter.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to