aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/monlib/encode/format.cpp
diff options
context:
space:
mode:
authorSergey Polovko <sergey@polovko.me>2022-02-10 16:47:03 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:03 +0300
commit2e714b5ebd40a1f4cc31c27f1ad6e49ca6d895f5 (patch)
treeb83306b6e37edeea782e9eed673d89286c4fef35 /library/cpp/monlib/encode/format.cpp
parent3e0b762a82514bac89c1dd6ea7211e381d8aa248 (diff)
downloadydb-2e714b5ebd40a1f4cc31c27f1ad6e49ca6d895f5.tar.gz
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/monlib/encode/format.cpp')
-rw-r--r--library/cpp/monlib/encode/format.cpp256
1 files changed, 128 insertions, 128 deletions
diff --git a/library/cpp/monlib/encode/format.cpp b/library/cpp/monlib/encode/format.cpp
index d9bb4fcd04..400ce5a643 100644
--- a/library/cpp/monlib/encode/format.cpp
+++ b/library/cpp/monlib/encode/format.cpp
@@ -1,12 +1,12 @@
-#include "format.h"
-
-#include <util/string/ascii.h>
+#include "format.h"
+
+#include <util/string/ascii.h>
#include <util/string/split.h>
-#include <util/string/strip.h>
-#include <util/stream/output.h>
-#include <util/string/cast.h>
-
-namespace NMonitoring {
+#include <util/string/strip.h>
+#include <util/stream/output.h>
+#include <util/string/cast.h>
+
+namespace NMonitoring {
static ECompression CompressionFromHeader(TStringBuf value) {
if (value.empty()) {
return ECompression::UNKNOWN;
@@ -38,165 +38,165 @@ namespace NMonitoring {
return EFormat::PROTOBUF;
} else if (AsciiEqualsIgnoreCase(value, NFormatContenType::TEXT)) {
return EFormat::TEXT;
- } else if (AsciiEqualsIgnoreCase(value, NFormatContenType::PROMETHEUS)) {
- return EFormat::PROMETHEUS;
- }
-
+ } else if (AsciiEqualsIgnoreCase(value, NFormatContenType::PROMETHEUS)) {
+ return EFormat::PROMETHEUS;
+ }
+
return EFormat::UNKNOWN;
}
EFormat FormatFromAcceptHeader(TStringBuf value) {
EFormat result{EFormat::UNKNOWN};
- for (const auto& it : StringSplitter(value).Split(',').SkipEmpty()) {
- TStringBuf token = StripString(it.Token());
-
+ for (const auto& it : StringSplitter(value).Split(',').SkipEmpty()) {
+ TStringBuf token = StripString(it.Token());
+
result = FormatFromHttpMedia(token);
if (result != EFormat::UNKNOWN) {
break;
- }
- }
-
+ }
+ }
+
return result;
- }
-
+ }
+
EFormat FormatFromContentType(TStringBuf value) {
value = value.NextTok(';');
return FormatFromHttpMedia(value);
}
- TStringBuf ContentTypeByFormat(EFormat format) {
- switch (format) {
- case EFormat::SPACK:
- return NFormatContenType::SPACK;
- case EFormat::JSON:
- return NFormatContenType::JSON;
- case EFormat::PROTOBUF:
- return NFormatContenType::PROTOBUF;
- case EFormat::TEXT:
- return NFormatContenType::TEXT;
- case EFormat::PROMETHEUS:
- return NFormatContenType::PROMETHEUS;
- case EFormat::UNKNOWN:
- return TStringBuf();
- }
-
- Y_FAIL(); // for GCC
- }
-
- ECompression CompressionFromAcceptEncodingHeader(TStringBuf value) {
+ TStringBuf ContentTypeByFormat(EFormat format) {
+ switch (format) {
+ case EFormat::SPACK:
+ return NFormatContenType::SPACK;
+ case EFormat::JSON:
+ return NFormatContenType::JSON;
+ case EFormat::PROTOBUF:
+ return NFormatContenType::PROTOBUF;
+ case EFormat::TEXT:
+ return NFormatContenType::TEXT;
+ case EFormat::PROMETHEUS:
+ return NFormatContenType::PROMETHEUS;
+ case EFormat::UNKNOWN:
+ return TStringBuf();
+ }
+
+ Y_FAIL(); // for GCC
+ }
+
+ ECompression CompressionFromAcceptEncodingHeader(TStringBuf value) {
return CompressionFromHeader(value);
}
-
+
ECompression CompressionFromContentEncodingHeader(TStringBuf value) {
return CompressionFromHeader(value);
- }
-
- TStringBuf ContentEncodingByCompression(ECompression compression) {
- switch (compression) {
- case ECompression::IDENTITY:
- return NFormatContentEncoding::IDENTITY;
- case ECompression::ZLIB:
- return NFormatContentEncoding::ZLIB;
- case ECompression::LZ4:
- return NFormatContentEncoding::LZ4;
- case ECompression::ZSTD:
- return NFormatContentEncoding::ZSTD;
- case ECompression::UNKNOWN:
- return TStringBuf();
- }
-
- Y_FAIL(); // for GCC
- }
-
-}
-
-template <>
-NMonitoring::EFormat FromStringImpl<NMonitoring::EFormat>(const char* str, size_t len) {
- using NMonitoring::EFormat;
- TStringBuf value(str, len);
+ }
+
+ TStringBuf ContentEncodingByCompression(ECompression compression) {
+ switch (compression) {
+ case ECompression::IDENTITY:
+ return NFormatContentEncoding::IDENTITY;
+ case ECompression::ZLIB:
+ return NFormatContentEncoding::ZLIB;
+ case ECompression::LZ4:
+ return NFormatContentEncoding::LZ4;
+ case ECompression::ZSTD:
+ return NFormatContentEncoding::ZSTD;
+ case ECompression::UNKNOWN:
+ return TStringBuf();
+ }
+
+ Y_FAIL(); // for GCC
+ }
+
+}
+
+template <>
+NMonitoring::EFormat FromStringImpl<NMonitoring::EFormat>(const char* str, size_t len) {
+ using NMonitoring::EFormat;
+ TStringBuf value(str, len);
if (value == TStringBuf("SPACK")) {
- return EFormat::SPACK;
+ return EFormat::SPACK;
} else if (value == TStringBuf("JSON")) {
- return EFormat::JSON;
+ return EFormat::JSON;
} else if (value == TStringBuf("PROTOBUF")) {
- return EFormat::PROTOBUF;
+ return EFormat::PROTOBUF;
} else if (value == TStringBuf("TEXT")) {
- return EFormat::TEXT;
+ return EFormat::TEXT;
} else if (value == TStringBuf("PROMETHEUS")) {
- return EFormat::PROMETHEUS;
+ return EFormat::PROMETHEUS;
} else if (value == TStringBuf("UNKNOWN")) {
- return EFormat::UNKNOWN;
- }
- ythrow yexception() << "unknown format: " << value;
-}
-
-template <>
-void Out<NMonitoring::EFormat>(IOutputStream& o, NMonitoring::EFormat f) {
- using NMonitoring::EFormat;
- switch (f) {
- case EFormat::SPACK:
+ return EFormat::UNKNOWN;
+ }
+ ythrow yexception() << "unknown format: " << value;
+}
+
+template <>
+void Out<NMonitoring::EFormat>(IOutputStream& o, NMonitoring::EFormat f) {
+ using NMonitoring::EFormat;
+ switch (f) {
+ case EFormat::SPACK:
o << TStringBuf("SPACK");
- return;
- case EFormat::JSON:
+ return;
+ case EFormat::JSON:
o << TStringBuf("JSON");
- return;
- case EFormat::PROTOBUF:
+ return;
+ case EFormat::PROTOBUF:
o << TStringBuf("PROTOBUF");
- return;
- case EFormat::TEXT:
+ return;
+ case EFormat::TEXT:
o << TStringBuf("TEXT");
- return;
- case EFormat::PROMETHEUS:
+ return;
+ case EFormat::PROMETHEUS:
o << TStringBuf("PROMETHEUS");
- return;
- case EFormat::UNKNOWN:
+ return;
+ case EFormat::UNKNOWN:
o << TStringBuf("UNKNOWN");
- return;
- }
-
- Y_FAIL(); // for GCC
-}
-
-template <>
-NMonitoring::ECompression FromStringImpl<NMonitoring::ECompression>(const char* str, size_t len) {
- using NMonitoring::ECompression;
- TStringBuf value(str, len);
+ return;
+ }
+
+ Y_FAIL(); // for GCC
+}
+
+template <>
+NMonitoring::ECompression FromStringImpl<NMonitoring::ECompression>(const char* str, size_t len) {
+ using NMonitoring::ECompression;
+ TStringBuf value(str, len);
if (value == TStringBuf("IDENTITY")) {
- return ECompression::IDENTITY;
+ return ECompression::IDENTITY;
} else if (value == TStringBuf("ZLIB")) {
- return ECompression::ZLIB;
+ return ECompression::ZLIB;
} else if (value == TStringBuf("LZ4")) {
- return ECompression::LZ4;
+ return ECompression::LZ4;
} else if (value == TStringBuf("ZSTD")) {
- return ECompression::ZSTD;
+ return ECompression::ZSTD;
} else if (value == TStringBuf("UNKNOWN")) {
- return ECompression::UNKNOWN;
- }
- ythrow yexception() << "unknown compression: " << value;
-}
-
-template <>
-void Out<NMonitoring::ECompression>(IOutputStream& o, NMonitoring::ECompression c) {
- using NMonitoring::ECompression;
- switch (c) {
- case ECompression::IDENTITY:
+ return ECompression::UNKNOWN;
+ }
+ ythrow yexception() << "unknown compression: " << value;
+}
+
+template <>
+void Out<NMonitoring::ECompression>(IOutputStream& o, NMonitoring::ECompression c) {
+ using NMonitoring::ECompression;
+ switch (c) {
+ case ECompression::IDENTITY:
o << TStringBuf("IDENTITY");
- return;
- case ECompression::ZLIB:
+ return;
+ case ECompression::ZLIB:
o << TStringBuf("ZLIB");
- return;
- case ECompression::LZ4:
+ return;
+ case ECompression::LZ4:
o << TStringBuf("LZ4");
- return;
- case ECompression::ZSTD:
+ return;
+ case ECompression::ZSTD:
o << TStringBuf("ZSTD");
- return;
- case ECompression::UNKNOWN:
+ return;
+ case ECompression::UNKNOWN:
o << TStringBuf("UNKNOWN");
- return;
- }
-
- Y_FAIL(); // for GCC
-}
+ return;
+ }
+
+ Y_FAIL(); // for GCC
+}