aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/handler.h
diff options
context:
space:
mode:
authornga <nga@yandex-team.ru>2022-02-10 16:48:09 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:09 +0300
commit1f553f46fb4f3c5eec631352cdd900a0709016af (patch)
treea231fba2c03b440becaea6c86a2702d0bfb0336e /library/cpp/messagebus/handler.h
parentc4de7efdedc25b49cbea74bd589eecb61b55b60a (diff)
downloadydb-1f553f46fb4f3c5eec631352cdd900a0709016af.tar.gz
Restoring authorship annotation for <nga@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/handler.h')
-rw-r--r--library/cpp/messagebus/handler.h64
1 files changed, 32 insertions, 32 deletions
diff --git a/library/cpp/messagebus/handler.h b/library/cpp/messagebus/handler.h
index 60002c68a6..d9df33814b 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&);
};
-
+
}