diff options
author | yegorskii <yegorskii@yandex-team.ru> | 2022-02-10 16:49:10 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:10 +0300 |
commit | 6c7ed19fb4e807d81f39d5b370b1dba604558a17 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/actors | |
parent | 7902ff9c26a2eacba73e7137a81aed2df9b3e9c1 (diff) | |
download | ydb-6c7ed19fb4e807d81f39d5b370b1dba604558a17.tar.gz |
Restoring authorship annotation for <yegorskii@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/actors')
-rw-r--r-- | library/cpp/actors/core/log_settings.cpp | 12 | ||||
-rw-r--r-- | library/cpp/actors/core/log_settings.h | 8 | ||||
-rw-r--r-- | library/cpp/actors/core/log_ut.cpp | 112 | ||||
-rw-r--r-- | library/cpp/actors/core/mon.h | 24 |
4 files changed, 78 insertions, 78 deletions
diff --git a/library/cpp/actors/core/log_settings.cpp b/library/cpp/actors/core/log_settings.cpp index e49abf4717..f52f2fc5d2 100644 --- a/library/cpp/actors/core/log_settings.cpp +++ b/library/cpp/actors/core/log_settings.cpp @@ -6,11 +6,11 @@ namespace NActors { namespace NLog { TSettings::TSettings(const TActorId& loggerActorId, const EComponent loggerComponent, EComponent minVal, EComponent maxVal, EComponentToStringFunc func, - EPriority defPriority, EPriority defSamplingPriority, - ui32 defSamplingRate, ui64 timeThresholdMs) + EPriority defPriority, EPriority defSamplingPriority, + ui32 defSamplingRate, ui64 timeThresholdMs) : LoggerActorId(loggerActorId) , LoggerComponent(loggerComponent) - , TimeThresholdMs(timeThresholdMs) + , TimeThresholdMs(timeThresholdMs) , AllowDrop(true) , ThrottleDelay(TDuration::MilliSeconds(100)) , MinVal(0) @@ -28,11 +28,11 @@ namespace NActors { } TSettings::TSettings(const TActorId& loggerActorId, const EComponent loggerComponent, - EPriority defPriority, EPriority defSamplingPriority, - ui32 defSamplingRate, ui64 timeThresholdMs) + EPriority defPriority, EPriority defSamplingPriority, + ui32 defSamplingRate, ui64 timeThresholdMs) : LoggerActorId(loggerActorId) , LoggerComponent(loggerComponent) - , TimeThresholdMs(timeThresholdMs) + , TimeThresholdMs(timeThresholdMs) , AllowDrop(true) , ThrottleDelay(TDuration::MilliSeconds(100)) , MinVal(0) diff --git a/library/cpp/actors/core/log_settings.h b/library/cpp/actors/core/log_settings.h index ebb689be09..7fe4504edd 100644 --- a/library/cpp/actors/core/log_settings.h +++ b/library/cpp/actors/core/log_settings.h @@ -100,12 +100,12 @@ namespace NActors { // YOURTYPE_Name for you. TSettings(const TActorId& loggerActorId, const EComponent loggerComponent, EComponent minVal, EComponent maxVal, EComponentToStringFunc func, - EPriority defPriority, EPriority defSamplingPriority = PRI_DEBUG, - ui32 defSamplingRate = 0, ui64 timeThresholdMs = 1000); + EPriority defPriority, EPriority defSamplingPriority = PRI_DEBUG, + ui32 defSamplingRate = 0, ui64 timeThresholdMs = 1000); TSettings(const TActorId& loggerActorId, const EComponent loggerComponent, - EPriority defPriority, EPriority defSamplingPriority = PRI_DEBUG, - ui32 defSamplingRate = 0, ui64 timeThresholdMs = 1000); + EPriority defPriority, EPriority defSamplingPriority = PRI_DEBUG, + ui32 defSamplingRate = 0, ui64 timeThresholdMs = 1000); void Append(EComponent minVal, EComponent maxVal, EComponentToStringFunc func); diff --git a/library/cpp/actors/core/log_ut.cpp b/library/cpp/actors/core/log_ut.cpp index d742357e3f..09b5f88ea2 100644 --- a/library/cpp/actors/core/log_ut.cpp +++ b/library/cpp/actors/core/log_ut.cpp @@ -22,19 +22,19 @@ namespace { return s; } - TIntrusivePtr<TSettings> DroppingSettings(ui64 timeThresholdMs) { - auto loggerId = TActorId{0, "Logger"}; - auto s = MakeIntrusive<TSettings>( - loggerId, - 0, - EPriority::PRI_TRACE, - EPriority::PRI_DEBUG, - (ui32)0, - timeThresholdMs); - s->Append(0, 1, ServiceToString); - return s; - } - + TIntrusivePtr<TSettings> DroppingSettings(ui64 timeThresholdMs) { + auto loggerId = TActorId{0, "Logger"}; + auto s = MakeIntrusive<TSettings>( + loggerId, + 0, + EPriority::PRI_TRACE, + EPriority::PRI_DEBUG, + (ui32)0, + timeThresholdMs); + s->Append(0, 1, ServiceToString); + return s; + } + class TMockBackend: public TLogBackend { public: using TWriteImpl = std::function<void(const TLogRecord&)>; @@ -68,30 +68,30 @@ namespace { }; struct TFixture { - TFixture( - TIntrusivePtr<TSettings> settings, - TMockBackend::TWriteImpl writeImpl = ThrowAlways) - { + TFixture( + TIntrusivePtr<TSettings> settings, + TMockBackend::TWriteImpl writeImpl = ThrowAlways) + { Runtime.Initialize(); LogBackend.reset(new TMockBackend{writeImpl}); - LoggerActor = Runtime.Register(new TLoggerActor{settings, LogBackend, Counters}); + LoggerActor = Runtime.Register(new TLoggerActor{settings, LogBackend, Counters}); Runtime.SetScheduledEventFilter([] (auto&&, auto&&, auto&&, auto) { return false; }); } - TFixture(TMockBackend::TWriteImpl writeImpl = ThrowAlways) - : TFixture(DefaultSettings(), writeImpl) - {} - + TFixture(TMockBackend::TWriteImpl writeImpl = ThrowAlways) + : TFixture(DefaultSettings(), writeImpl) + {} + void WriteLog() { Runtime.Send(new IEventHandle{LoggerActor, {}, new TEvLog(TInstant::Zero(), TLevel{EPrio::Emerg}, 0, "foo")}); } - void WriteLog(TInstant ts) { - Runtime.Send(new IEventHandle{LoggerActor, {}, new TEvLog(ts, TLevel{EPrio::Emerg}, 0, "foo")}); - } - + void WriteLog(TInstant ts) { + Runtime.Send(new IEventHandle{LoggerActor, {}, new TEvLog(ts, TLevel{EPrio::Emerg}, 0, "foo")}); + } + void Wakeup() { Runtime.Send(new IEventHandle{LoggerActor, {}, new TEvents::TEvWakeup}); } @@ -152,34 +152,34 @@ Y_UNIT_TEST_SUITE(TLoggerActorTest) { UNIT_ASSERT_VALUES_EQUAL(messages.size(), COUNT); } - - Y_UNIT_TEST(ShouldObeyTimeThresholdMsWhenOverloaded) { - TFixture test{DroppingSettings(5000)}; - - TVector<TString> messages; - auto acceptWrites = [&] (const TLogRecord& r) { - messages.emplace_back(r.Data, r.Len); - }; - - test.LogBackend->SetWriteImpl(acceptWrites); - test.Wakeup(); - - const auto COUNT = 11; - for (auto i = 0; i < COUNT; ++i) { - test.WriteLog(); - } - - UNIT_ASSERT_VALUES_EQUAL(messages.size(), COUNT); - - test.Runtime.AdvanceCurrentTime(TDuration::Seconds(20)); - auto now = test.Runtime.GetCurrentTime(); - - test.WriteLog(now - TDuration::Seconds(5)); - - UNIT_ASSERT_VALUES_EQUAL(messages.size(), COUNT + 1); - - test.WriteLog(now - TDuration::Seconds(6)); - - UNIT_ASSERT_VALUES_EQUAL(messages.size(), COUNT + 1); - } + + Y_UNIT_TEST(ShouldObeyTimeThresholdMsWhenOverloaded) { + TFixture test{DroppingSettings(5000)}; + + TVector<TString> messages; + auto acceptWrites = [&] (const TLogRecord& r) { + messages.emplace_back(r.Data, r.Len); + }; + + test.LogBackend->SetWriteImpl(acceptWrites); + test.Wakeup(); + + const auto COUNT = 11; + for (auto i = 0; i < COUNT; ++i) { + test.WriteLog(); + } + + UNIT_ASSERT_VALUES_EQUAL(messages.size(), COUNT); + + test.Runtime.AdvanceCurrentTime(TDuration::Seconds(20)); + auto now = test.Runtime.GetCurrentTime(); + + test.WriteLog(now - TDuration::Seconds(5)); + + UNIT_ASSERT_VALUES_EQUAL(messages.size(), COUNT + 1); + + test.WriteLog(now - TDuration::Seconds(6)); + + UNIT_ASSERT_VALUES_EQUAL(messages.size(), COUNT + 1); + } } diff --git a/library/cpp/actors/core/mon.h b/library/cpp/actors/core/mon.h index 3854356fa8..c450f2338e 100644 --- a/library/cpp/actors/core/mon.h +++ b/library/cpp/actors/core/mon.h @@ -88,14 +88,14 @@ namespace NActors { { } - TEvRemoteHttpInfo(const TString& query, HTTP_METHOD method) - : Query(query) - , Method(method) - { - } - + TEvRemoteHttpInfo(const TString& query, HTTP_METHOD method) + : Query(query) + , Method(method) + { + } + TString Query; - HTTP_METHOD Method; + HTTP_METHOD Method; TString PathInfo() const { const size_t pos = Query.find('?'); @@ -126,11 +126,11 @@ namespace NActors { static IEventBase* Load(TEventSerializedData* bufs) { return new TEvRemoteHttpInfo(bufs->GetString()); } - - HTTP_METHOD GetMethod() const - { - return Method; - } + + HTTP_METHOD GetMethod() const + { + return Method; + } }; struct TEvRemoteHttpInfoRes: public NActors::TEventBase<TEvRemoteHttpInfoRes, RemoteHttpInfoRes> { |