diff options
| author | nga <[email protected]> | 2022-02-10 16:48:09 +0300 | 
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:48:09 +0300 | 
| commit | c2a1af049e9deca890e9923abe64fe6c59060348 (patch) | |
| tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/monlib/deprecated | |
| parent | 1f553f46fb4f3c5eec631352cdd900a0709016af (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/deprecated')
| -rw-r--r-- | library/cpp/monlib/deprecated/json/ut/ya.make | 12 | ||||
| -rw-r--r-- | library/cpp/monlib/deprecated/json/writer.cpp | 34 | ||||
| -rw-r--r-- | library/cpp/monlib/deprecated/json/writer.h | 92 | ||||
| -rw-r--r-- | library/cpp/monlib/deprecated/json/writer_ut.cpp | 38 | ||||
| -rw-r--r-- | library/cpp/monlib/deprecated/json/ya.make | 18 | 
5 files changed, 97 insertions, 97 deletions
diff --git a/library/cpp/monlib/deprecated/json/ut/ya.make b/library/cpp/monlib/deprecated/json/ut/ya.make index 556b0c8291b..18315993b51 100644 --- a/library/cpp/monlib/deprecated/json/ut/ya.make +++ b/library/cpp/monlib/deprecated/json/ut/ya.make @@ -1,12 +1,12 @@  UNITTEST_FOR(library/cpp/monlib/deprecated/json) -  +  OWNER(      jamel      g:solomon  ) -  -SRCS(  + +SRCS(      writer_ut.cpp -)  -  -END()  +) + +END() diff --git a/library/cpp/monlib/deprecated/json/writer.cpp b/library/cpp/monlib/deprecated/json/writer.cpp index 99172886876..a581f2e07ac 100644 --- a/library/cpp/monlib/deprecated/json/writer.cpp +++ b/library/cpp/monlib/deprecated/json/writer.cpp @@ -1,36 +1,36 @@  #include "writer.h" -  +  namespace NMonitoring {      TDeprecatedJsonWriter::TDeprecatedJsonWriter(IOutputStream* out)          : JsonWriter(out, false)          , State(STATE_ROOT)      {      } -  +      void TDeprecatedJsonWriter::TransitionState(EState current, EState next) {          if (State != current) {              ythrow yexception() << "wrong state";          }          State = next;      } -  +      void TDeprecatedJsonWriter::OpenDocument() {          TransitionState(STATE_ROOT, STATE_DOCUMENT);          JsonWriter.OpenMap(); -    }  -  +    } +      void TDeprecatedJsonWriter::CloseDocument() {          TransitionState(STATE_DOCUMENT, STATE_ROOT);          JsonWriter.CloseMap();          JsonWriter.Flush();      } -  +      void TDeprecatedJsonWriter::OpenCommonLabels() {          TransitionState(STATE_DOCUMENT, STATE_COMMON_LABELS);          JsonWriter.Write("commonLabels");          JsonWriter.OpenMap();      } -  +      void TDeprecatedJsonWriter::CloseCommonLabels() {          TransitionState(STATE_COMMON_LABELS, STATE_DOCUMENT);          JsonWriter.CloseMap(); @@ -51,50 +51,50 @@ namespace NMonitoring {          TransitionState(STATE_METRICS, STATE_DOCUMENT);          JsonWriter.CloseArray();      } -  +      void TDeprecatedJsonWriter::OpenMetric() {          TransitionState(STATE_METRICS, STATE_METRIC);          JsonWriter.OpenMap();      } -  +      void TDeprecatedJsonWriter::CloseMetric() {          TransitionState(STATE_METRIC, STATE_METRICS);          JsonWriter.CloseMap();      } -  +      void TDeprecatedJsonWriter::OpenLabels() {          TransitionState(STATE_METRIC, STATE_LABELS);          JsonWriter.Write("labels");          JsonWriter.OpenMap();      } -  +      void TDeprecatedJsonWriter::CloseLabels() {          TransitionState(STATE_LABELS, STATE_METRIC);          JsonWriter.CloseMap();      } -  +      void TDeprecatedJsonWriter::WriteLabel(TStringBuf name, TStringBuf value) {          TransitionState(STATE_LABELS, STATE_LABELS);          JsonWriter.Write(name, value);      } -  +      void TDeprecatedJsonWriter::WriteModeDeriv() {          TransitionState(STATE_METRIC, STATE_METRIC);          JsonWriter.Write("mode", "deriv");      } -  +      void TDeprecatedJsonWriter::WriteValue(long long value) {          TransitionState(STATE_METRIC, STATE_METRIC);          JsonWriter.Write("value", value);      } -  +      void TDeprecatedJsonWriter::WriteDoubleValue(double value) {          TransitionState(STATE_METRIC, STATE_METRIC);          JsonWriter.Write("value", value);      } -  +      void TDeprecatedJsonWriter::WriteTs(ui64 ts) {          TransitionState(STATE_METRIC, STATE_METRIC);          JsonWriter.Write("ts", ts);      } -}  +} diff --git a/library/cpp/monlib/deprecated/json/writer.h b/library/cpp/monlib/deprecated/json/writer.h index 2ea8ce40c16..183288143c1 100644 --- a/library/cpp/monlib/deprecated/json/writer.h +++ b/library/cpp/monlib/deprecated/json/writer.h @@ -1,7 +1,7 @@ -#pragma once  -  +#pragma once +  #include <library/cpp/json/json_writer.h> -  +  namespace NMonitoring {      /**       * Deprecated writer of Solomon JSON format @@ -12,24 +12,24 @@ namespace NMonitoring {       * particular format.       */      class TDeprecatedJsonWriter { -    private:  -        NJson::TJsonWriter JsonWriter;  -        enum EState {  -            STATE_ROOT,  -            STATE_DOCUMENT,  +    private: +        NJson::TJsonWriter JsonWriter; +        enum EState { +            STATE_ROOT, +            STATE_DOCUMENT,              STATE_COMMON_LABELS,              STATE_METRICS,              STATE_METRIC, -            STATE_LABELS,  -        };  -        EState State;  +            STATE_LABELS, +        }; +        EState State; -    public:  +    public:          explicit TDeprecatedJsonWriter(IOutputStream* out); -  -        void OpenDocument();  -        void CloseDocument();  -  + +        void OpenDocument(); +        void CloseDocument(); +          void OpenCommonLabels();          void CloseCommonLabels(); @@ -37,40 +37,40 @@ namespace NMonitoring {          void OpenMetrics();          void CloseMetrics(); -  +          void OpenMetric();          void CloseMetric(); -  -        void OpenLabels();  -        void CloseLabels();  -  -        void WriteLabel(TStringBuf name, TStringBuf value);  -  -        template <typename... T>  -        void WriteLabels(T... pairs) {  -            OpenLabels();  -            WriteLabelsInner(pairs...);  -            CloseLabels();  -        }  -  -        void WriteModeDeriv();  -  -        void WriteValue(long long value);  -        void WriteDoubleValue(double d);  + +        void OpenLabels(); +        void CloseLabels(); + +        void WriteLabel(TStringBuf name, TStringBuf value); + +        template <typename... T> +        void WriteLabels(T... pairs) { +            OpenLabels(); +            WriteLabelsInner(pairs...); +            CloseLabels(); +        } + +        void WriteModeDeriv(); + +        void WriteValue(long long value); +        void WriteDoubleValue(double d);          void WriteTs(ui64 ts); -    private:  -        void WriteLabelsInner(TStringBuf name, TStringBuf value) {  -            WriteLabel(name, value);  -        }  -  +    private: +        void WriteLabelsInner(TStringBuf name, TStringBuf value) { +            WriteLabel(name, value); +        } +          template <typename... T> -        void WriteLabelsInner(TStringBuf name, TStringBuf value, T... pairs) {  -            WriteLabel(name, value);  -            WriteLabelsInner(pairs...);  -        }  -  -        inline void TransitionState(EState current, EState next);  -    };  +        void WriteLabelsInner(TStringBuf name, TStringBuf value, T... pairs) { +            WriteLabel(name, value); +            WriteLabelsInner(pairs...); +        } + +        inline void TransitionState(EState current, EState next); +    };  } diff --git a/library/cpp/monlib/deprecated/json/writer_ut.cpp b/library/cpp/monlib/deprecated/json/writer_ut.cpp index cd5c4e4d780..1f9fc8f3933 100644 --- a/library/cpp/monlib/deprecated/json/writer_ut.cpp +++ b/library/cpp/monlib/deprecated/json/writer_ut.cpp @@ -1,32 +1,32 @@  #include "writer.h"  #include <library/cpp/testing/unittest/registar.h> -  +  using namespace NMonitoring; -  +  Y_UNIT_TEST_SUITE(JsonWriterTests) {      Y_UNIT_TEST(One) { -        TStringStream ss;  +        TStringStream ss;          TDeprecatedJsonWriter w(&ss); -        w.OpenDocument();  +        w.OpenDocument();          w.OpenMetrics(); -  -        for (int i = 0; i < 5; ++i) {  + +        for (int i = 0; i < 5; ++i) {              w.OpenMetric(); -            w.OpenLabels();  +            w.OpenLabels();              w.WriteLabel("user", TString("") + (char)('a' + i));              w.WriteLabel("name", "NWrites"); -            w.CloseLabels();  -            if (i % 2 == 0) {  -                w.WriteModeDeriv();  -            }  -            w.WriteValue(10l);  +            w.CloseLabels(); +            if (i % 2 == 0) { +                w.WriteModeDeriv(); +            } +            w.WriteValue(10l);              w.CloseMetric(); -        }  -  +        } +          w.CloseMetrics(); -        w.CloseDocument();  -  -        //Cout << ss.Str() << "\n";  -    }  -}  +        w.CloseDocument(); + +        //Cout << ss.Str() << "\n"; +    } +} diff --git a/library/cpp/monlib/deprecated/json/ya.make b/library/cpp/monlib/deprecated/json/ya.make index cf49d7367bd..0ca903ee62b 100644 --- a/library/cpp/monlib/deprecated/json/ya.make +++ b/library/cpp/monlib/deprecated/json/ya.make @@ -1,26 +1,26 @@ -LIBRARY()  -  +LIBRARY() +  # Deprecated writer of Solomon JSON format -# https://wiki.yandex-team.ru/solomon/api/dataformat/json  +# https://wiki.yandex-team.ru/solomon/api/dataformat/json  #  # This writer will be deleted soon, so please consider to use  # high level library library/cpp/monlib/encode which is decoupled from the  # particular format. -  +  OWNER(      jamel      g:solomon  ) -  +  SRCS(      writer.h      writer.cpp  ) -PEERDIR(  +PEERDIR(      library/cpp/json -)  -  -END()  +) + +END()  RECURSE_FOR_TESTS(ut)  | 
