This repository was archived by the owner on Aug 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Factor MetadataStore, MetadataReporter, and MetadataAgent into their own files. #87
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1ccb224
Replace an std::bind instance missed in #74.
igorpeshansky b2aed76
Factor out MetadataStore from MetadataAgent.
igorpeshansky 1561cfa
Keep all MetadataStore functions together.
igorpeshansky 8e9c078
Use MetadataStore::Metadata instead of MetadataAgent::Metadata.
igorpeshansky d6a9a88
Pull out MetadataStore into a separate file.
igorpeshansky e0338bb
Pull out MetadataReporter into a separate file.
igorpeshansky 029b06f
Pull out MetadataAgent into a separate file.
igorpeshansky 715ab18
Stop using MetadataAgent as a wrapper around config+store.
igorpeshansky a9e65ad
Forward-declare MetadataAgentConfiguration in agent.h.
igorpeshansky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright 2018 Google Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| **/ | ||
|
|
||
| #include "agent.h" | ||
|
|
||
| #include "configuration.h" | ||
| #include "api_server.h" | ||
| #include "reporter.h" | ||
|
|
||
| namespace google { | ||
|
|
||
| MetadataAgent::MetadataAgent(const MetadataAgentConfiguration& config) | ||
| : config_(config), store_(config_) {} | ||
|
|
||
| MetadataAgent::~MetadataAgent() {} | ||
|
|
||
| void MetadataAgent::start() { | ||
| metadata_api_server_.reset(new MetadataApiServer( | ||
| config_, store_, config_.MetadataApiNumThreads(), "0.0.0.0", | ||
| config_.MetadataApiPort())); | ||
| reporter_.reset(new MetadataReporter( | ||
| config_, &store_, config_.MetadataReporterIntervalSeconds())); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Copyright 2018 Google Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| **/ | ||
| #ifndef AGENT_H_ | ||
| #define AGENT_H_ | ||
|
|
||
| //#include "config.h" | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "store.h" | ||
|
|
||
| namespace google { | ||
|
|
||
| // Configuration object. | ||
| class MetadataAgentConfiguration; | ||
|
|
||
| // A server that implements the metadata agent API. | ||
| class MetadataApiServer; | ||
|
|
||
| // A periodic reporter of metadata to Stackdriver. | ||
| class MetadataReporter; | ||
|
|
||
| // Runs the metadata tasks. | ||
| class MetadataAgent { | ||
| public: | ||
| MetadataAgent(const MetadataAgentConfiguration& config); | ||
| ~MetadataAgent(); | ||
|
|
||
| // Starts serving. | ||
| void start(); | ||
|
|
||
| const MetadataAgentConfiguration& config() const { | ||
| return config_; | ||
| } | ||
|
|
||
| const MetadataStore& store() const { | ||
| return store_; | ||
| } | ||
|
|
||
| MetadataStore* mutable_store() { | ||
| return &store_; | ||
| } | ||
|
|
||
| private: | ||
| const MetadataAgentConfiguration& config_; | ||
|
|
||
| // The store for the metadata. | ||
| MetadataStore store_; | ||
|
|
||
| // The Metadata API server. | ||
| std::unique_ptr<MetadataApiServer> metadata_api_server_; | ||
| // The metadata reporter. | ||
| std::unique_ptr<MetadataReporter> reporter_; | ||
| }; | ||
|
|
||
| } | ||
|
|
||
| #endif // AGENT_H_ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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's remove unnecessary imports, same throughout.
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.
This specific one was a "reminder" to set up autotools to make this more portable. It appears all over the place. Probably no sense in keeping it, but I'd rather do it as a separate cleanup to keep this PR focused.