Browse Source

Restoring authorship annotation for <jon2205@yandex-team.ru>. Commit 2 of 2.

jon2205 3 years ago
parent
commit
fa48a9aebc

+ 1 - 1
library/cpp/monlib/counters/timer.h

@@ -166,7 +166,7 @@ namespace NMonitoring {
                 (*Callback_)(duration);
             }
             Timer_->RecordValue(duration);
-        } 
+        }
 
     private:
         TTimer* Timer_;

+ 24 - 24
library/cpp/monlib/counters/timer_ut.cpp

@@ -5,17 +5,17 @@
 using namespace NMonitoring;
 using namespace std::literals::chrono_literals;
 
-class TCallback { 
-public: 
+class TCallback {
+public:
     explicit TCallback(int value)
         : Value_(value){};
-    void operator()(std::chrono::high_resolution_clock::duration duration) { 
-        Value_ = duration.count(); 
-    }; 
- 
-    int Value_; 
-}; 
- 
+    void operator()(std::chrono::high_resolution_clock::duration duration) {
+        Value_ = duration.count();
+    };
+
+    int Value_;
+};
+
 Y_UNIT_TEST_SUITE(TTimerTest) {
     Y_UNIT_TEST(RecordValue) {
         TTimerNs timerNs(1ns, 1s);
@@ -62,20 +62,20 @@ Y_UNIT_TEST_SUITE(TTimerTest) {
         UNIT_ASSERT(snapshot.Max > std::chrono::microseconds(10ms).count());
         UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6);
     }
- 
+
     Y_UNIT_TEST(TimerScopeWithCallback) {
-        TCallback callback(0); 
-        TTimerUs timer(1us, 1000s); 
-        { 
-            TTimerScope<TTimerUs, TCallback> scope(&timer, &callback); 
-            Sleep(TDuration::MilliSeconds(10)); 
-        } 
-        THistogramSnapshot snapshot; 
-        timer.TakeSnapshot(&snapshot); 
- 
-        UNIT_ASSERT(snapshot.Min > std::chrono::microseconds(10ms).count()); 
-        UNIT_ASSERT(snapshot.Max > std::chrono::microseconds(10ms).count()); 
-        UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6); 
-        UNIT_ASSERT(callback.Value_ > std::chrono::microseconds(10ms).count()); 
-    } 
+        TCallback callback(0);
+        TTimerUs timer(1us, 1000s);
+        {
+            TTimerScope<TTimerUs, TCallback> scope(&timer, &callback);
+            Sleep(TDuration::MilliSeconds(10));
+        }
+        THistogramSnapshot snapshot;
+        timer.TakeSnapshot(&snapshot);
+
+        UNIT_ASSERT(snapshot.Min > std::chrono::microseconds(10ms).count());
+        UNIT_ASSERT(snapshot.Max > std::chrono::microseconds(10ms).count());
+        UNIT_ASSERT_DOUBLES_EQUAL(snapshot.StdDeviation, 0.0, 1e-6);
+        UNIT_ASSERT(callback.Value_ > std::chrono::microseconds(10ms).count());
+    }
 }

+ 65 - 65
library/cpp/monlib/dynamic_counters/golovan_page.cpp

@@ -1,79 +1,79 @@
 #include "golovan_page.h"
- 
+
 #include <library/cpp/monlib/service/pages/templates.h>
- 
-#include <util/string/split.h> 
-#include <util/system/tls.h> 
- 
-using namespace NMonitoring; 
- 
-class TGolovanCountableConsumer: public ICountableConsumer { 
-public: 
-    using TOutputCallback = std::function<void()>; 
- 
-    TGolovanCountableConsumer(IOutputStream& out, TOutputCallback& OutputCallback) 
-        : out(out) 
-    { 
-        if (OutputCallback) { 
-            OutputCallback(); 
-        } 
- 
-        out << HTTPOKJSON << "["; 
-        FirstCounter = true; 
-    } 
- 
+
+#include <util/string/split.h>
+#include <util/system/tls.h>
+
+using namespace NMonitoring;
+
+class TGolovanCountableConsumer: public ICountableConsumer {
+public:
+    using TOutputCallback = std::function<void()>;
+
+    TGolovanCountableConsumer(IOutputStream& out, TOutputCallback& OutputCallback)
+        : out(out)
+    {
+        if (OutputCallback) {
+            OutputCallback();
+        }
+
+        out << HTTPOKJSON << "[";
+        FirstCounter = true;
+    }
+
     void OnCounter(const TString&, const TString& value, const TCounterForPtr* counter) override {
-        if (FirstCounter) { 
-            FirstCounter = false; 
-        } else { 
-            out << ","; 
-        } 
- 
-        out << "[\"" << prefix + value; 
-        if (counter->ForDerivative()) { 
+        if (FirstCounter) {
+            FirstCounter = false;
+        } else {
+            out << ",";
+        }
+
+        out << "[\"" << prefix + value;
+        if (counter->ForDerivative()) {
             out << "_dmmm";
-        } else { 
-            out << "_ahhh"; 
-        } 
- 
-        out << "\"," << counter->Val() << "]"; 
-    } 
- 
+        } else {
+            out << "_ahhh";
+        }
+
+        out << "\"," << counter->Val() << "]";
+    }
+
     void OnHistogram(const TString&, const TString&, IHistogramSnapshotPtr, bool) override {
     }
 
     void OnGroupBegin(const TString&, const TString& value, const TDynamicCounters*) override {
-        prefix += value; 
+        prefix += value;
         if (!value.empty()) {
-            prefix += "_"; 
-        } 
-    } 
- 
+            prefix += "_";
+        }
+    }
+
     void OnGroupEnd(const TString&, const TString&, const TDynamicCounters*) override {
-        prefix = ""; 
-    } 
- 
-    void Flush() { 
-        out << "]"; 
-        out.Flush(); 
-    } 
- 
-private: 
+        prefix = "";
+    }
+
+    void Flush() {
+        out << "]";
+        out.Flush();
+    }
+
+private:
     IOutputStream& out;
-    bool FirstCounter; 
+    bool FirstCounter;
     TString prefix;
-}; 
- 
-TGolovanCountersPage::TGolovanCountersPage(const TString& path, TIntrusivePtr<NMonitoring::TDynamicCounters> counters, 
-                                           TOutputCallback outputCallback) 
-    : IMonPage(path) 
-    , Counters(counters) 
-    , OutputCallback(outputCallback) 
-{ 
-} 
- 
+};
+
+TGolovanCountersPage::TGolovanCountersPage(const TString& path, TIntrusivePtr<NMonitoring::TDynamicCounters> counters,
+                                           TOutputCallback outputCallback)
+    : IMonPage(path)
+    , Counters(counters)
+    , OutputCallback(outputCallback)
+{
+}
+
 void TGolovanCountersPage::Output(IMonHttpRequest& request) {
     TGolovanCountableConsumer consumer(request.Output(), OutputCallback);
-    Counters->Accept("", "", consumer); 
-    consumer.Flush(); 
-} 
+    Counters->Accept("", "", consumer);
+    consumer.Flush();
+}

+ 21 - 21
library/cpp/monlib/dynamic_counters/golovan_page.h

@@ -1,25 +1,25 @@
-#pragma once 
- 
+#pragma once
+
 #include "counters.h"
- 
+
 #include <library/cpp/monlib/service/pages/mon_page.h>
- 
-#include <util/generic/ptr.h> 
- 
-#include <functional> 
- 
-// helper class to output json for Golovan. 
-class TGolovanCountersPage: public NMonitoring::IMonPage { 
-public: 
-    using TOutputCallback = std::function<void()>; 
- 
-    const TIntrusivePtr<NMonitoring::TDynamicCounters> Counters; 
- 
-    TGolovanCountersPage(const TString& path, TIntrusivePtr<NMonitoring::TDynamicCounters> counters, 
-                         TOutputCallback outputCallback = nullptr); 
- 
+
+#include <util/generic/ptr.h>
+
+#include <functional>
+
+// helper class to output json for Golovan.
+class TGolovanCountersPage: public NMonitoring::IMonPage {
+public:
+    using TOutputCallback = std::function<void()>;
+
+    const TIntrusivePtr<NMonitoring::TDynamicCounters> Counters;
+
+    TGolovanCountersPage(const TString& path, TIntrusivePtr<NMonitoring::TDynamicCounters> counters,
+                         TOutputCallback outputCallback = nullptr);
+
     void Output(NMonitoring::IMonHttpRequest& request) override;
 
-private: 
-    TOutputCallback OutputCallback; 
-}; 
+private:
+    TOutputCallback OutputCallback;
+};

+ 4 - 4
util/datetime/parser.h

@@ -95,10 +95,10 @@ struct TDateTimeFields {
 };
 
 class TDateTimeParserBase {
-public: 
-    const TDateTimeFields& GetDateTimeFields() const { 
-        return DateTimeFields; 
-    } 
+public:
+    const TDateTimeFields& GetDateTimeFields() const {
+        return DateTimeFields;
+    }
 
 protected:
     TDateTimeFields DateTimeFields;