-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add proof of concept with weather data
- Loading branch information
Showing
20 changed files
with
1,340 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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,222 @@ | ||
--- | ||
Language: Cpp | ||
# BasedOnStyle: LLVM | ||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: Align | ||
AlignArrayOfStructures: None | ||
AlignConsecutiveAssignments: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
PadOperators: true | ||
AlignConsecutiveBitFields: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
PadOperators: false | ||
AlignConsecutiveDeclarations: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
PadOperators: false | ||
AlignConsecutiveMacros: | ||
Enabled: false | ||
AcrossEmptyLines: false | ||
AcrossComments: false | ||
AlignCompound: false | ||
PadOperators: false | ||
AlignEscapedNewlines: Right | ||
AlignOperands: Align | ||
AlignTrailingComments: | ||
Kind: Always | ||
OverEmptyLines: 0 | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: Never | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortEnumsOnASingleLine: true | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: MultiLine | ||
AttributeMacros: | ||
- __capability | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BitFieldColonSpacing: Both | ||
BraceWrapping: | ||
AfterCaseLabel: true | ||
AfterClass: false | ||
AfterControlStatement: Never | ||
AfterEnum: false | ||
AfterExternBlock: false | ||
AfterFunction: true | ||
AfterNamespace: false | ||
AfterObjCDeclaration: true | ||
AfterStruct: false | ||
AfterUnion: true | ||
BeforeCatch: false | ||
BeforeElse: false | ||
BeforeLambdaBody: false | ||
BeforeWhile: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakAfterAttributes: Never | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakArrays: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeConceptDeclarations: Always | ||
BreakBeforeBraces: Custom | ||
BreakBeforeInlineASMColon: OnlyMultiline | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializers: BeforeColon | ||
BreakInheritanceList: BeforeColon | ||
BreakStringLiterals: true | ||
ColumnLimit: 120 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: true | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
EmptyLineAfterAccessModifier: Never | ||
EmptyLineBeforeAccessModifier: LogicalBlock | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: true | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IfMacros: | ||
- KJ_IF_MAYBE | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
Priority: 3 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
- Regex: '.*' | ||
Priority: 1 | ||
SortPriority: 0 | ||
CaseSensitive: false | ||
IncludeIsMainRegex: '(Test)?$' | ||
IncludeIsMainSourceRegex: '' | ||
IndentAccessModifiers: false | ||
IndentCaseBlocks: false | ||
IndentCaseLabels: false | ||
IndentExternBlock: AfterExternBlock | ||
IndentGotoLabels: true | ||
IndentPPDirectives: None | ||
IndentRequiresClause: true | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
InsertBraces: false | ||
InsertNewlineAtEOF: true | ||
InsertTrailingCommas: None | ||
IntegerLiteralSeparator: | ||
Binary: 0 | ||
Decimal: 0 | ||
Hex: 0 | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
LambdaBodyIndentation: Signature | ||
LineEnding: DeriveLF | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 2 | ||
ObjCBreakBeforeNestedBlockParam: true | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: true | ||
PackConstructorInitializers: BinPack | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakOpenParenthesis: 0 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyIndentedWhitespace: 0 | ||
PenaltyReturnTypeOnItsOwnLine: 60 | ||
PointerAlignment: Right | ||
PPIndentWidth: -1 | ||
QualifierAlignment: Leave | ||
ReferenceAlignment: Pointer | ||
ReflowComments: true | ||
RemoveBracesLLVM: false | ||
RemoveSemicolon: false | ||
RequiresClausePosition: OwnLine | ||
RequiresExpressionIndentation: OuterScope | ||
SeparateDefinitionBlocks: Leave | ||
ShortNamespaceLines: 1 | ||
SortIncludes: CaseSensitive | ||
SortJavaStaticImport: Before | ||
SortUsingDeclarations: LexicographicNumeric | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceAroundPointerQualifiers: Default | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCaseColon: false | ||
SpaceBeforeCpp11BracedList: false | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeParensOptions: | ||
AfterControlStatements: true | ||
AfterForeachMacros: true | ||
AfterFunctionDefinitionName: false | ||
AfterFunctionDeclarationName: false | ||
AfterIfMacros: true | ||
AfterOverloadedOperator: false | ||
AfterRequiresInClause: false | ||
AfterRequiresInExpression: false | ||
BeforeNonEmptyParentheses: false | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceBeforeSquareBrackets: false | ||
SpaceInEmptyBlock: false | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: Never | ||
SpacesInConditionalStatement: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInLineCommentPrefix: | ||
Minimum: 1 | ||
Maximum: -1 | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Latest | ||
StatementAttributeLikeMacros: | ||
- Q_EMIT | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 8 | ||
UseTab: Never | ||
WhitespaceSensitiveMacros: | ||
- BOOST_PP_STRINGIZE | ||
- CF_SWIFT_NAME | ||
- NS_SWIFT_NAME | ||
- PP_STRINGIZE | ||
- STRINGIZE | ||
... | ||
|
This file contains 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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
build | ||
.env | ||
.cache | ||
|
||
debian/.debhelper | ||
debian/chestnut* | ||
|
This file contains 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 |
---|---|---|
@@ -1,7 +1,31 @@ | ||
add_executable(chestnut | ||
chestnut.cpp | ||
chestnut.m.cpp | ||
config.cpp | ||
weather/weatherclient.cpp | ||
weather/weatherdata.cpp | ||
weather/weatherdatapublisher.cpp | ||
) | ||
target_include_directories(chestnut PUBLIC .) | ||
target_link_libraries(chestnut pthread) | ||
target_link_libraries(chestnut pthread fwoopbasis fwoophttp fwoopbasis fwoopencoding fwoopobserve) | ||
|
||
install(TARGETS chestnut DESTINATION /opt/bin) | ||
|
||
include(GoogleTest) | ||
add_executable(chestnut_test | ||
chestnut.g.cpp | ||
config.g.cpp | ||
weather/weatherclient.g.cpp | ||
weather/weatherdata.g.cpp | ||
weather/weatherdatapublisher.g.cpp | ||
|
||
chestnut.cpp | ||
config.cpp | ||
weather/weatherclient.cpp | ||
weather/weatherdata.cpp | ||
weather/weatherdatapublisher.cpp | ||
) | ||
target_include_directories(chestnut_test PUBLIC .) | ||
target_link_libraries(chestnut_test fwoopobserve fwoopbasis fwoophttp fwoopbasis fwoopencoding fwoopobserve gtest gtest_main pthread) | ||
|
||
gtest_add_tests(TARGET chestnut_test) |
This file contains 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,53 @@ | ||
#include <chestnut.h> | ||
|
||
#include <chrono> | ||
#include <config.h> | ||
#include <functional> | ||
#include <memory> | ||
#include <publisher.h> | ||
#include <thread> | ||
|
||
#include <fwoop_log.h> | ||
|
||
namespace chestnut { | ||
|
||
Chestnut::Chestnut() | ||
: d_publisher(std::make_shared<OpenMetricsPublisher>(Config::metricsPort())), | ||
d_weatherClient(std::make_shared<WeatherClient>(Config::weatherBaseURL(), Config::weatherLat(), | ||
Config::weatherLon(), Config::weatherAPIKey())), | ||
d_needStop(false) | ||
{ | ||
} | ||
|
||
Chestnut::Chestnut(std::shared_ptr<Publisher> publisher) : d_publisher(publisher), d_needStop(false) {} | ||
|
||
void Chestnut::refresh() | ||
{ | ||
while (!d_needStop) { | ||
if (Config::isWeatherEnabled()) { | ||
d_weatherClient->refresh(); | ||
} | ||
std::this_thread::sleep_for(std::chrono::seconds(Config::refreshInterval())); | ||
} | ||
} | ||
|
||
int Chestnut::start() | ||
{ | ||
if (!Config::debug()) { | ||
fwoop::Log::SetThreshold(fwoop::Log::e_Info); | ||
} | ||
|
||
d_publisher->start(); | ||
d_weatherClient->setPublisher(d_publisher); | ||
refresh(); | ||
return 0; | ||
} | ||
|
||
void Chestnut::stop() | ||
{ | ||
d_needStop = true; | ||
d_publisher->stop(); | ||
d_refreshThread.join(); | ||
} | ||
|
||
} // namespace chestnut |
This file contains 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 @@ | ||
#include <chestnut.h> |
This file contains 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,36 @@ | ||
#pragma once | ||
|
||
#include <memory.h> | ||
|
||
#include <memory> | ||
#include <publisher.h> | ||
#include <thread> | ||
#include <weather/weatherclient.h> | ||
|
||
namespace chestnut { | ||
|
||
class Chestnut { | ||
private: | ||
std::shared_ptr<Publisher> d_publisher; | ||
std::shared_ptr<WeatherClient> d_weatherClient; | ||
std::thread d_refreshThread; | ||
bool d_needStop; | ||
|
||
void refresh(); | ||
|
||
public: | ||
Chestnut(); | ||
Chestnut(std::shared_ptr<Publisher> publisher); | ||
|
||
~Chestnut(); | ||
Chestnut(const Chestnut &rhs) = delete; | ||
Chestnut &operator=(const Chestnut &rhs) = delete; | ||
Chestnut(Chestnut &&rhs) = default; | ||
|
||
int start(); | ||
void stop(); | ||
}; | ||
|
||
inline Chestnut::~Chestnut() { stop(); } | ||
|
||
} // namespace chestnut |
This file contains 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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#include "chestnut.h" | ||
#include <fwoop_log.h> | ||
#include <iostream> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
std::cout << "hello\n"; | ||
return 0; | ||
} | ||
int main(int argc, char *argv[]) { return chestnut::Chestnut().start(); } |
Oops, something went wrong.