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 | c2a1af049e9deca890e9923abe64fe6c59060348 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/messagebus/handler.h | |
parent | 1f553f46fb4f3c5eec631352cdd900a0709016af (diff) | |
download | ydb-c2a1af049e9deca890e9923abe64fe6c59060348.tar.gz |
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/messagebus/handler.h')
-rw-r--r-- | library/cpp/messagebus/handler.h | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/library/cpp/messagebus/handler.h b/library/cpp/messagebus/handler.h index d9df33814b..60002c68a6 100644 --- a/library/cpp/messagebus/handler.h +++ b/library/cpp/messagebus/handler.h @@ -1,44 +1,44 @@ -#pragma once - -#include "defs.h" +#pragma once + +#include "defs.h" #include "message.h" -#include "message_status.h" -#include "use_after_free_checker.h" -#include "use_count_checker.h" - +#include "message_status.h" +#include "use_after_free_checker.h" +#include "use_count_checker.h" + #include <util/generic/noncopyable.h> -namespace NBus { +namespace NBus { ///////////////////////////////////////////////////////////////// /// \brief Interface to message bus handler - + struct IBusErrorHandler { friend struct ::NBus::NPrivate::TBusSessionImpl; - + private: TUseAfterFreeChecker UseAfterFreeChecker; TUseCountChecker UseCountChecker; - + public: /// called when message or reply can't be delivered virtual void OnError(TAutoPtr<TBusMessage> pMessage, EMessageStatus status); - + virtual ~IBusErrorHandler() { } }; - + class TClientConnectionEvent { public: enum EType { CONNECTED, DISCONNECTED, }; - + private: EType Type; ui64 Id; TNetAddr Addr; - + public: TClientConnectionEvent(EType type, ui64 id, TNetAddr addr) : Type(type) @@ -56,15 +56,15 @@ namespace NBus { TNetAddr GetAddr() const { return Addr; } - }; - + }; + class TOnMessageContext : TNonCopyable { private: THolder<TBusMessage> Message; TBusIdentity Ident; // TODO: we don't need to store session, we have connection in ident TBusServerSession* Session; - + public: TOnMessageContext() : Session() @@ -76,53 +76,53 @@ namespace NBus { { Ident.Swap(ident); } - + bool IsInWork() const { return Ident.IsInWork(); } - + bool operator!() const { return !IsInWork(); } - + TBusMessage* GetMessage() { return Message.Get(); } - + TBusMessage* ReleaseMessage() { return Message.Release(); } - + TBusServerSession* GetSession() { return Session; } - + template <typename U /* <: TBusMessage */> EMessageStatus SendReplyAutoPtr(TAutoPtr<U>& rep); - + EMessageStatus SendReplyMove(TBusMessageAutoPtr response); - + void AckMessage(TBusIdentity& ident); - + void ForgetRequest(); - + void Swap(TOnMessageContext& that) { DoSwap(Message, that.Message); Ident.Swap(that.Ident); DoSwap(Session, that.Session); } - + TNetAddr GetPeerAddrNetAddr() const; bool IsConnectionAlive() const; }; - + struct IBusServerHandler: public IBusErrorHandler { virtual void OnMessage(TOnMessageContext& onMessage) = 0; /// called when reply has been sent from destination virtual void OnSent(TAutoPtr<TBusMessage> pMessage); }; - + struct IBusClientHandler: public IBusErrorHandler { /// called on source when reply arrives from destination virtual void OnReply(TAutoPtr<TBusMessage> pMessage, TAutoPtr<TBusMessage> pReply) = 0; @@ -131,5 +131,5 @@ namespace NBus { virtual void OnMessageSentOneWay(TAutoPtr<TBusMessage> pMessage); virtual void OnClientConnectionEvent(const TClientConnectionEvent&); }; - + } |