Pass SonarState into SonarWebSocketImpl

Summary: Allowing the connection code to update trigger diagnostic events

Reviewed By: danielbuechele

Differential Revision: D9150554

fbshipit-source-id: 5fe0a08edc2f3b0ccae43b4dc2c7b087c6404c58
This commit is contained in:
John Knox
2018-08-07 09:42:13 -07:00
committed by Facebook Github Bot
parent 531a47535b
commit 55ca14ee41
5 changed files with 25 additions and 21 deletions

View File

@@ -39,9 +39,8 @@ class SonarClient : public SonarWebSocket::Callbacks {
/**
Only public for testing
*/
SonarClient(std::unique_ptr<SonarWebSocket> socket)
: socket_(std::move(socket)) {
sonarState_ = std::make_unique<SonarState>();
SonarClient(std::unique_ptr<SonarWebSocket> socket, std::shared_ptr<SonarState> state)
: socket_(std::move(socket)), sonarState_(state) {
auto step = sonarState_->start("Create client");
socket_->setCallbacks(this);
step->complete();
@@ -92,7 +91,7 @@ class SonarClient : public SonarWebSocket::Callbacks {
std::map<std::string, std::shared_ptr<SonarPlugin>> plugins_;
std::map<std::string, std::shared_ptr<SonarConnectionImpl>> connections_;
std::mutex mutex_;
std::unique_ptr<SonarState> sonarState_;
std::shared_ptr<SonarState> sonarState_;
void performAndReportError(const std::function<void()>& func);
void disconnect(std::shared_ptr<SonarPlugin> plugin);