diff options
author | nga <nga@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:09 +0300 |
commit | 1f553f46fb4f3c5eec631352cdd900a0709016af (patch) | |
tree | a231fba2c03b440becaea6c86a2702d0bfb0336e /library/cpp/messagebus/debug_receiver | |
parent | c4de7efdedc25b49cbea74bd589eecb61b55b60a (diff) | |
download | ydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/debug_receiver')
6 files changed, 98 insertions, 98 deletions
diff --git a/library/cpp/messagebus/debug_receiver/debug_receiver.cpp b/library/cpp/messagebus/debug_receiver/debug_receiver.cpp index 23b02d1003..dfd3d0f1c9 100644 --- a/library/cpp/messagebus/debug_receiver/debug_receiver.cpp +++ b/library/cpp/messagebus/debug_receiver/debug_receiver.cpp @@ -1,42 +1,42 @@ #include "debug_receiver_handler.h" #include "debug_receiver_proto.h" - + #include <library/cpp/messagebus/ybus.h> #include <library/cpp/getopt/last_getopt.h> #include <library/cpp/lwtrace/all.h> - -using namespace NBus; - -int main(int argc, char** argv) { - NLWTrace::StartLwtraceFromEnv(); - - TBusQueueConfig queueConfig; - TBusServerSessionConfig sessionConfig; - - NLastGetopt::TOpts opts; - - queueConfig.ConfigureLastGetopt(opts); - sessionConfig.ConfigureLastGetopt(opts); - - opts.AddLongOption("port").Required().RequiredArgument("PORT").StoreResult(&sessionConfig.ListenPort); - - opts.SetFreeArgsMax(0); - - NLastGetopt::TOptsParseResult r(&opts, argc, argv); - - TBusMessageQueuePtr q(CreateMessageQueue(queueConfig)); - - TDebugReceiverProtocol proto; - TDebugReceiverHandler handler; - - TBusServerSessionPtr serverSession = TBusServerSession::Create(&proto, &handler, sessionConfig, q); - // TODO: race is here - handler.ServerSession = serverSession.Get(); - - for (;;) { - Sleep(TDuration::Hours(17)); - } - - return 0; -} + +using namespace NBus; + +int main(int argc, char** argv) { + NLWTrace::StartLwtraceFromEnv(); + + TBusQueueConfig queueConfig; + TBusServerSessionConfig sessionConfig; + + NLastGetopt::TOpts opts; + + queueConfig.ConfigureLastGetopt(opts); + sessionConfig.ConfigureLastGetopt(opts); + + opts.AddLongOption("port").Required().RequiredArgument("PORT").StoreResult(&sessionConfig.ListenPort); + + opts.SetFreeArgsMax(0); + + NLastGetopt::TOptsParseResult r(&opts, argc, argv); + + TBusMessageQueuePtr q(CreateMessageQueue(queueConfig)); + + TDebugReceiverProtocol proto; + TDebugReceiverHandler handler; + + TBusServerSessionPtr serverSession = TBusServerSession::Create(&proto, &handler, sessionConfig, q); + // TODO: race is here + handler.ServerSession = serverSession.Get(); + + for (;;) { + Sleep(TDuration::Hours(17)); + } + + return 0; +} diff --git a/library/cpp/messagebus/debug_receiver/debug_receiver_handler.cpp b/library/cpp/messagebus/debug_receiver/debug_receiver_handler.cpp index 05f99e94ca..7490ae17c7 100644 --- a/library/cpp/messagebus/debug_receiver/debug_receiver_handler.cpp +++ b/library/cpp/messagebus/debug_receiver/debug_receiver_handler.cpp @@ -1,20 +1,20 @@ #include "debug_receiver_handler.h" - -#include "debug_receiver_proto.h" - + +#include "debug_receiver_proto.h" + #include <util/generic/cast.h> #include <util/string/printf.h> - + void TDebugReceiverHandler::OnError(TAutoPtr<NBus::TBusMessage>, NBus::EMessageStatus status) { - Cerr << "error " << status << "\n"; -} - + Cerr << "error " << status << "\n"; +} + void TDebugReceiverHandler::OnMessage(NBus::TOnMessageContext& message) { - TDebugReceiverMessage* typedMessage = VerifyDynamicCast<TDebugReceiverMessage*>(message.GetMessage()); - Cerr << "type=" << typedMessage->GetHeader()->Type + TDebugReceiverMessage* typedMessage = VerifyDynamicCast<TDebugReceiverMessage*>(message.GetMessage()); + Cerr << "type=" << typedMessage->GetHeader()->Type << " size=" << typedMessage->GetHeader()->Size << " flags=" << Sprintf("0x%04x", (int)typedMessage->GetHeader()->FlagsInternal) << "\n"; - - message.ForgetRequest(); -} + + message.ForgetRequest(); +} diff --git a/library/cpp/messagebus/debug_receiver/debug_receiver_handler.h b/library/cpp/messagebus/debug_receiver/debug_receiver_handler.h index 0aed6b9984..5a280fb537 100644 --- a/library/cpp/messagebus/debug_receiver/debug_receiver_handler.h +++ b/library/cpp/messagebus/debug_receiver/debug_receiver_handler.h @@ -1,10 +1,10 @@ -#pragma once - +#pragma once + #include <library/cpp/messagebus/ybus.h> - + struct TDebugReceiverHandler: public NBus::IBusServerHandler { - NBus::TBusServerSession* ServerSession; - + NBus::TBusServerSession* ServerSession; + void OnError(TAutoPtr<NBus::TBusMessage> pMessage, NBus::EMessageStatus status) override; void OnMessage(NBus::TOnMessageContext& message) override; -}; +}; diff --git a/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp b/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp index 0c74f9ecc3..50990dae03 100644 --- a/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp +++ b/library/cpp/messagebus/debug_receiver/debug_receiver_proto.cpp @@ -1,20 +1,20 @@ -#include "debug_receiver_proto.h" - -using namespace NBus; - -TDebugReceiverProtocol::TDebugReceiverProtocol() - : TBusProtocol("debug receiver", 0) -{ -} - +#include "debug_receiver_proto.h" + +using namespace NBus; + +TDebugReceiverProtocol::TDebugReceiverProtocol() + : TBusProtocol("debug receiver", 0) +{ +} + void TDebugReceiverProtocol::Serialize(const NBus::TBusMessage*, TBuffer&) { Y_FAIL("it is receiver only"); -} - +} + TAutoPtr<NBus::TBusMessage> TDebugReceiverProtocol::Deserialize(ui16, TArrayRef<const char> payload) { - THolder<TDebugReceiverMessage> r(new TDebugReceiverMessage(ECreateUninitialized())); - - r->Payload.Append(payload.data(), payload.size()); - - return r.Release(); -} + THolder<TDebugReceiverMessage> r(new TDebugReceiverMessage(ECreateUninitialized())); + + r->Payload.Append(payload.data(), payload.size()); + + return r.Release(); +} diff --git a/library/cpp/messagebus/debug_receiver/debug_receiver_proto.h b/library/cpp/messagebus/debug_receiver/debug_receiver_proto.h index d34710dcf7..90c01444fb 100644 --- a/library/cpp/messagebus/debug_receiver/debug_receiver_proto.h +++ b/library/cpp/messagebus/debug_receiver/debug_receiver_proto.h @@ -1,27 +1,27 @@ -#pragma once - +#pragma once + #include <library/cpp/messagebus/ybus.h> - + struct TDebugReceiverMessage: public NBus::TBusMessage { - /// constructor to create messages on sending end + /// constructor to create messages on sending end TDebugReceiverMessage(ui16 type) : NBus::TBusMessage(type) { } - - /// constructor with serialzed data to examine the header + + /// constructor with serialzed data to examine the header TDebugReceiverMessage(NBus::ECreateUninitialized) : NBus::TBusMessage(NBus::ECreateUninitialized()) { } - - TBuffer Payload; -}; - + + TBuffer Payload; +}; + struct TDebugReceiverProtocol: public NBus::TBusProtocol { - TDebugReceiverProtocol(); - + TDebugReceiverProtocol(); + void Serialize(const NBus::TBusMessage* mess, TBuffer& data) override; - + TAutoPtr<NBus::TBusMessage> Deserialize(ui16 messageType, TArrayRef<const char> payload) override; -}; +}; diff --git a/library/cpp/messagebus/debug_receiver/ya.make b/library/cpp/messagebus/debug_receiver/ya.make index f1b14d35bb..dd498e41cb 100644 --- a/library/cpp/messagebus/debug_receiver/ya.make +++ b/library/cpp/messagebus/debug_receiver/ya.make @@ -1,17 +1,17 @@ -PROGRAM(messagebus_debug_receiver) - +PROGRAM(messagebus_debug_receiver) + OWNER(g:messagebus) - -SRCS( - debug_receiver.cpp - debug_receiver_proto.cpp - debug_receiver_handler.cpp -) - -PEERDIR( + +SRCS( + debug_receiver.cpp + debug_receiver_proto.cpp + debug_receiver_handler.cpp +) + +PEERDIR( library/cpp/getopt library/cpp/lwtrace library/cpp/messagebus -) - -END() +) + +END() |