aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/config
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/messagebus/config
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/messagebus/config')
-rw-r--r--library/cpp/messagebus/config/defs.h90
-rw-r--r--library/cpp/messagebus/config/netaddr.cpp296
-rw-r--r--library/cpp/messagebus/config/netaddr.h134
-rw-r--r--library/cpp/messagebus/config/session_config.cpp108
-rw-r--r--library/cpp/messagebus/config/session_config.h90
5 files changed, 359 insertions, 359 deletions
diff --git a/library/cpp/messagebus/config/defs.h b/library/cpp/messagebus/config/defs.h
index 92b1df9969..ad644cd279 100644
--- a/library/cpp/messagebus/config/defs.h
+++ b/library/cpp/messagebus/config/defs.h
@@ -1,5 +1,5 @@
#pragma once
-
+
// unique tag to fix pragma once gcc glueing: ./library/cpp/messagebus/defs.h
#include "codegen.h"
@@ -18,65 +18,65 @@ class TCrawlerModule;
struct TDebugReceiverHandler;
namespace NBus {
- namespace NPrivate {
- class TAcceptor;
- struct TBusSessionImpl;
- class TRemoteServerSession;
- class TRemoteClientSession;
- class TRemoteConnection;
- class TRemoteServerConnection;
- class TRemoteClientConnection;
- class TBusSyncSourceSessionImpl;
+ namespace NPrivate {
+ class TAcceptor;
+ struct TBusSessionImpl;
+ class TRemoteServerSession;
+ class TRemoteClientSession;
+ class TRemoteConnection;
+ class TRemoteServerConnection;
+ class TRemoteClientConnection;
+ class TBusSyncSourceSessionImpl;
- struct TBusMessagePtrAndHeader;
+ struct TBusMessagePtrAndHeader;
- struct TSessionDumpStatus;
+ struct TSessionDumpStatus;
- struct TClientRequestImpl;
+ struct TClientRequestImpl;
- }
+ }
- class TBusSession;
- struct TBusServerSession;
- struct TBusClientSession;
- class TBusProtocol;
- class TBusMessage;
- class TBusMessageConnection;
- class TBusMessageQueue;
- class TBusLocator;
- struct TBusQueueConfig;
- struct TBusSessionConfig;
- struct TBusHeader;
+ class TBusSession;
+ struct TBusServerSession;
+ struct TBusClientSession;
+ class TBusProtocol;
+ class TBusMessage;
+ class TBusMessageConnection;
+ class TBusMessageQueue;
+ class TBusLocator;
+ struct TBusQueueConfig;
+ struct TBusSessionConfig;
+ struct TBusHeader;
- class IThreadHandler;
+ class IThreadHandler;
- using TBusKey = ui64;
- using TBusMessageList = TList<TBusMessage*>;
- using TBusKeyVec = TVector<std::pair<TBusKey, TBusKey>>;
+ using TBusKey = ui64;
+ using TBusMessageList = TList<TBusMessage*>;
+ using TBusKeyVec = TVector<std::pair<TBusKey, TBusKey>>;
- using TBusMessageQueuePtr = TIntrusivePtr<TBusMessageQueue>;
+ using TBusMessageQueuePtr = TIntrusivePtr<TBusMessageQueue>;
- class TBusModule;
+ class TBusModule;
- using TBusData = TString;
- using TBusService = const char*;
+ using TBusData = TString;
+ using TBusService = const char*;
-#define YBUS_KEYMIN TBusKey(0L)
-#define YBUS_KEYMAX TBusKey(-1L)
-#define YBUS_KEYLOCAL TBusKey(7L)
+#define YBUS_KEYMIN TBusKey(0L)
+#define YBUS_KEYMAX TBusKey(-1L)
+#define YBUS_KEYLOCAL TBusKey(7L)
#define YBUS_KEYINVALID TBusKey(99999999L)
- // Check that generated id is valid for remote message
- inline bool IsBusKeyValid(TBusKey key) {
- return key != YBUS_KEYINVALID && key != YBUS_KEYMAX && key > YBUS_KEYLOCAL;
- }
+ // Check that generated id is valid for remote message
+ inline bool IsBusKeyValid(TBusKey key) {
+ return key != YBUS_KEYINVALID && key != YBUS_KEYMAX && key > YBUS_KEYLOCAL;
+ }
-#define YBUS_VERSION 0
+#define YBUS_VERSION 0
-#define YBUS_INFINITE (1u << 30u)
+#define YBUS_INFINITE (1u << 30u)
-#define YBUS_STATUS_BASIC 0x0000
-#define YBUS_STATUS_CONNS 0x0001
+#define YBUS_STATUS_BASIC 0x0000
+#define YBUS_STATUS_CONNS 0x0001
#define YBUS_STATUS_INFLIGHT 0x0002
-}
+}
diff --git a/library/cpp/messagebus/config/netaddr.cpp b/library/cpp/messagebus/config/netaddr.cpp
index 962ac538e2..73081240a0 100644
--- a/library/cpp/messagebus/config/netaddr.cpp
+++ b/library/cpp/messagebus/config/netaddr.cpp
@@ -5,175 +5,175 @@
#include <cstdlib>
namespace NBus {
- const char* ToCString(EIpVersion ipVersion) {
- switch (ipVersion) {
- case EIP_VERSION_ANY:
- return "EIP_VERSION_ANY";
- case EIP_VERSION_4:
- return "EIP_VERSION_4";
- case EIP_VERSION_6:
- return "EIP_VERSION_6";
+ const char* ToCString(EIpVersion ipVersion) {
+ switch (ipVersion) {
+ case EIP_VERSION_ANY:
+ return "EIP_VERSION_ANY";
+ case EIP_VERSION_4:
+ return "EIP_VERSION_4";
+ case EIP_VERSION_6:
+ return "EIP_VERSION_6";
+ }
+ Y_FAIL();
+ }
+
+ int ToAddrFamily(EIpVersion ipVersion) {
+ switch (ipVersion) {
+ case EIP_VERSION_ANY:
+ return AF_UNSPEC;
+ case EIP_VERSION_4:
+ return AF_INET;
+ case EIP_VERSION_6:
+ return AF_INET6;
+ }
+ Y_FAIL();
+ }
+
+ class TNetworkAddressRef: private TNetworkAddress, public TAddrInfo {
+ public:
+ TNetworkAddressRef(const TNetworkAddress& na, const TAddrInfo& ai)
+ : TNetworkAddress(na)
+ , TAddrInfo(ai)
+ {
+ }
+ };
+
+ static bool Compare(const IRemoteAddr& l, const IRemoteAddr& r) noexcept {
+ if (l.Addr()->sa_family != r.Addr()->sa_family) {
+ return false;
+ }
+
+ switch (l.Addr()->sa_family) {
+ case AF_INET: {
+ return memcmp(&(((const sockaddr_in*)l.Addr())->sin_addr), &(((const sockaddr_in*)r.Addr())->sin_addr), sizeof(in_addr)) == 0 &&
+ ((const sockaddr_in*)l.Addr())->sin_port == ((const sockaddr_in*)r.Addr())->sin_port;
+ }
+
+ case AF_INET6: {
+ return memcmp(&(((const sockaddr_in6*)l.Addr())->sin6_addr), &(((const sockaddr_in6*)r.Addr())->sin6_addr), sizeof(in6_addr)) == 0 &&
+ ((const sockaddr_in6*)l.Addr())->sin6_port == ((const sockaddr_in6*)r.Addr())->sin6_port;
+ }
}
- Y_FAIL();
- }
-
- int ToAddrFamily(EIpVersion ipVersion) {
- switch (ipVersion) {
- case EIP_VERSION_ANY:
- return AF_UNSPEC;
- case EIP_VERSION_4:
- return AF_INET;
- case EIP_VERSION_6:
- return AF_INET6;
- }
- Y_FAIL();
- }
-
- class TNetworkAddressRef: private TNetworkAddress, public TAddrInfo {
- public:
- TNetworkAddressRef(const TNetworkAddress& na, const TAddrInfo& ai)
- : TNetworkAddress(na)
- , TAddrInfo(ai)
- {
- }
- };
-
- static bool Compare(const IRemoteAddr& l, const IRemoteAddr& r) noexcept {
- if (l.Addr()->sa_family != r.Addr()->sa_family) {
- return false;
- }
-
- switch (l.Addr()->sa_family) {
- case AF_INET: {
- return memcmp(&(((const sockaddr_in*)l.Addr())->sin_addr), &(((const sockaddr_in*)r.Addr())->sin_addr), sizeof(in_addr)) == 0 &&
- ((const sockaddr_in*)l.Addr())->sin_port == ((const sockaddr_in*)r.Addr())->sin_port;
- }
-
- case AF_INET6: {
- return memcmp(&(((const sockaddr_in6*)l.Addr())->sin6_addr), &(((const sockaddr_in6*)r.Addr())->sin6_addr), sizeof(in6_addr)) == 0 &&
- ((const sockaddr_in6*)l.Addr())->sin6_port == ((const sockaddr_in6*)r.Addr())->sin6_port;
- }
- }
-
- return memcmp(l.Addr(), r.Addr(), Min<size_t>(l.Len(), r.Len())) == 0;
- }
-
- TNetAddr::TNetAddr()
- : Ptr(new TOpaqueAddr)
- {
- }
- TNetAddr::TNetAddr(TAutoPtr<IRemoteAddr> addr)
- : Ptr(addr)
- {
- Y_VERIFY(!!Ptr);
- }
-
- namespace {
- using namespace NAddr;
-
- const char* Describe(EIpVersion version) {
- switch (version) {
- case EIP_VERSION_4:
- return "ipv4 address";
- case EIP_VERSION_6:
- return "ipv6 address";
- case EIP_VERSION_ANY:
- return "any address";
- default:
- Y_FAIL("unreachable");
- }
+ return memcmp(l.Addr(), r.Addr(), Min<size_t>(l.Len(), r.Len())) == 0;
+ }
+
+ TNetAddr::TNetAddr()
+ : Ptr(new TOpaqueAddr)
+ {
+ }
+
+ TNetAddr::TNetAddr(TAutoPtr<IRemoteAddr> addr)
+ : Ptr(addr)
+ {
+ Y_VERIFY(!!Ptr);
+ }
+
+ namespace {
+ using namespace NAddr;
+
+ const char* Describe(EIpVersion version) {
+ switch (version) {
+ case EIP_VERSION_4:
+ return "ipv4 address";
+ case EIP_VERSION_6:
+ return "ipv6 address";
+ case EIP_VERSION_ANY:
+ return "any address";
+ default:
+ Y_FAIL("unreachable");
+ }
}
- TAutoPtr<IRemoteAddr> MakeAddress(const TNetworkAddress& na, EIpVersion requireVersion, EIpVersion preferVersion) {
- TAutoPtr<IRemoteAddr> addr;
- for (TNetworkAddress::TIterator it = na.Begin(); it != na.End(); ++it) {
- if (IsFamilyAllowed(it->ai_family, requireVersion)) {
- if (IsFamilyAllowed(it->ai_family, preferVersion)) {
- return new TNetworkAddressRef(na, &*it);
- } else if (!addr) {
- addr.Reset(new TNetworkAddressRef(na, &*it));
- }
+ TAutoPtr<IRemoteAddr> MakeAddress(const TNetworkAddress& na, EIpVersion requireVersion, EIpVersion preferVersion) {
+ TAutoPtr<IRemoteAddr> addr;
+ for (TNetworkAddress::TIterator it = na.Begin(); it != na.End(); ++it) {
+ if (IsFamilyAllowed(it->ai_family, requireVersion)) {
+ if (IsFamilyAllowed(it->ai_family, preferVersion)) {
+ return new TNetworkAddressRef(na, &*it);
+ } else if (!addr) {
+ addr.Reset(new TNetworkAddressRef(na, &*it));
+ }
}
}
- return addr;
+ return addr;
}
- TAutoPtr<IRemoteAddr> MakeAddress(TStringBuf host, int port, EIpVersion requireVersion, EIpVersion preferVersion) {
- TString hostString(host);
- TNetworkAddress na(hostString, port);
- return MakeAddress(na, requireVersion, preferVersion);
- }
- TAutoPtr<IRemoteAddr> MakeAddress(const char* hostPort, EIpVersion requireVersion, EIpVersion preferVersion) {
- const char* portStr = strchr(hostPort, ':');
- if (!portStr) {
- ythrow TNetAddr::TError() << "port not specified in " << hostPort;
- }
- int port = atoi(portStr + 1);
- TNetworkAddress na(TString(hostPort, portStr), port);
- return MakeAddress(na, requireVersion, preferVersion);
+ TAutoPtr<IRemoteAddr> MakeAddress(TStringBuf host, int port, EIpVersion requireVersion, EIpVersion preferVersion) {
+ TString hostString(host);
+ TNetworkAddress na(hostString, port);
+ return MakeAddress(na, requireVersion, preferVersion);
+ }
+ TAutoPtr<IRemoteAddr> MakeAddress(const char* hostPort, EIpVersion requireVersion, EIpVersion preferVersion) {
+ const char* portStr = strchr(hostPort, ':');
+ if (!portStr) {
+ ythrow TNetAddr::TError() << "port not specified in " << hostPort;
+ }
+ int port = atoi(portStr + 1);
+ TNetworkAddress na(TString(hostPort, portStr), port);
+ return MakeAddress(na, requireVersion, preferVersion);
+ }
+ }
+
+ TNetAddr::TNetAddr(const char* hostPort, EIpVersion requireVersion /*= EIP_VERSION_ANY*/, EIpVersion preferVersion /*= EIP_VERSION_ANY*/)
+ : Ptr(MakeAddress(hostPort, requireVersion, preferVersion))
+ {
+ if (!Ptr) {
+ ythrow TNetAddr::TError() << "cannot resolve " << hostPort << " into " << Describe(requireVersion);
+ }
+ }
+
+ TNetAddr::TNetAddr(TStringBuf host, int port, EIpVersion requireVersion /*= EIP_VERSION_ANY*/, EIpVersion preferVersion /*= EIP_VERSION_ANY*/)
+ : Ptr(MakeAddress(host, port, requireVersion, preferVersion))
+ {
+ if (!Ptr) {
+ ythrow TNetAddr::TError() << "cannot resolve " << host << ":" << port << " into " << Describe(requireVersion);
}
}
- TNetAddr::TNetAddr(const char* hostPort, EIpVersion requireVersion /*= EIP_VERSION_ANY*/, EIpVersion preferVersion /*= EIP_VERSION_ANY*/)
- : Ptr(MakeAddress(hostPort, requireVersion, preferVersion))
- {
- if (!Ptr) {
- ythrow TNetAddr::TError() << "cannot resolve " << hostPort << " into " << Describe(requireVersion);
- }
+ TNetAddr::TNetAddr(const TNetworkAddress& na, EIpVersion requireVersion /*= EIP_VERSION_ANY*/, EIpVersion preferVersion /*= EIP_VERSION_ANY*/)
+ : Ptr(MakeAddress(na, requireVersion, preferVersion))
+ {
+ if (!Ptr) {
+ ythrow TNetAddr::TError() << "cannot resolve into " << Describe(requireVersion);
+ }
}
- TNetAddr::TNetAddr(TStringBuf host, int port, EIpVersion requireVersion /*= EIP_VERSION_ANY*/, EIpVersion preferVersion /*= EIP_VERSION_ANY*/)
- : Ptr(MakeAddress(host, port, requireVersion, preferVersion))
- {
- if (!Ptr) {
- ythrow TNetAddr::TError() << "cannot resolve " << host << ":" << port << " into " << Describe(requireVersion);
- }
+ TNetAddr::TNetAddr(const TNetworkAddress& na, const TAddrInfo& ai)
+ : Ptr(new TNetworkAddressRef(na, ai))
+ {
}
- TNetAddr::TNetAddr(const TNetworkAddress& na, EIpVersion requireVersion /*= EIP_VERSION_ANY*/, EIpVersion preferVersion /*= EIP_VERSION_ANY*/)
- : Ptr(MakeAddress(na, requireVersion, preferVersion))
- {
- if (!Ptr) {
- ythrow TNetAddr::TError() << "cannot resolve into " << Describe(requireVersion);
- }
+ const sockaddr* TNetAddr::Addr() const {
+ return Ptr->Addr();
}
- TNetAddr::TNetAddr(const TNetworkAddress& na, const TAddrInfo& ai)
- : Ptr(new TNetworkAddressRef(na, ai))
- {
- }
+ socklen_t TNetAddr::Len() const {
+ return Ptr->Len();
+ }
- const sockaddr* TNetAddr::Addr() const {
- return Ptr->Addr();
- }
-
- socklen_t TNetAddr::Len() const {
- return Ptr->Len();
- }
-
- int TNetAddr::GetPort() const {
- switch (Ptr->Addr()->sa_family) {
- case AF_INET:
- return InetToHost(((sockaddr_in*)Ptr->Addr())->sin_port);
- case AF_INET6:
- return InetToHost(((sockaddr_in6*)Ptr->Addr())->sin6_port);
- default:
- Y_FAIL("unknown AF: %d", (int)Ptr->Addr()->sa_family);
- throw 1;
- }
- }
+ int TNetAddr::GetPort() const {
+ switch (Ptr->Addr()->sa_family) {
+ case AF_INET:
+ return InetToHost(((sockaddr_in*)Ptr->Addr())->sin_port);
+ case AF_INET6:
+ return InetToHost(((sockaddr_in6*)Ptr->Addr())->sin6_port);
+ default:
+ Y_FAIL("unknown AF: %d", (int)Ptr->Addr()->sa_family);
+ throw 1;
+ }
+ }
- bool TNetAddr::IsIpv4() const {
- return Ptr->Addr()->sa_family == AF_INET;
- }
+ bool TNetAddr::IsIpv4() const {
+ return Ptr->Addr()->sa_family == AF_INET;
+ }
- bool TNetAddr::IsIpv6() const {
- return Ptr->Addr()->sa_family == AF_INET6;
+ bool TNetAddr::IsIpv6() const {
+ return Ptr->Addr()->sa_family == AF_INET6;
}
- bool TNetAddr::operator==(const TNetAddr& rhs) const {
- return Ptr == rhs.Ptr || Compare(*Ptr, *rhs.Ptr);
- }
+ bool TNetAddr::operator==(const TNetAddr& rhs) const {
+ return Ptr == rhs.Ptr || Compare(*Ptr, *rhs.Ptr);
+ }
}
diff --git a/library/cpp/messagebus/config/netaddr.h b/library/cpp/messagebus/config/netaddr.h
index b79c0cc355..839f3d8f5d 100644
--- a/library/cpp/messagebus/config/netaddr.h
+++ b/library/cpp/messagebus/config/netaddr.h
@@ -8,79 +8,79 @@
#include <util/network/address.h>
namespace NBus {
- using namespace NAddr;
-
- /// IP protocol version.
- enum EIpVersion {
- EIP_VERSION_4 = 1,
- EIP_VERSION_6 = 2,
- EIP_VERSION_ANY = EIP_VERSION_4 | EIP_VERSION_6,
- };
-
- inline bool IsFamilyAllowed(ui16 sa_family, EIpVersion ipVersion) {
- if (ipVersion == EIP_VERSION_4 && sa_family != AF_INET) {
- return false;
- }
- if (ipVersion == EIP_VERSION_6 && sa_family != AF_INET6) {
- return false;
- }
- return true;
+ using namespace NAddr;
+
+ /// IP protocol version.
+ enum EIpVersion {
+ EIP_VERSION_4 = 1,
+ EIP_VERSION_6 = 2,
+ EIP_VERSION_ANY = EIP_VERSION_4 | EIP_VERSION_6,
+ };
+
+ inline bool IsFamilyAllowed(ui16 sa_family, EIpVersion ipVersion) {
+ if (ipVersion == EIP_VERSION_4 && sa_family != AF_INET) {
+ return false;
+ }
+ if (ipVersion == EIP_VERSION_6 && sa_family != AF_INET6) {
+ return false;
+ }
+ return true;
}
- const char* ToCString(EIpVersion);
- int ToAddrFamily(EIpVersion);
-
- /// Hold referenced pointer to address description structure (ex. sockaddr_storage)
- /// It's make possible to work with IPv4 / IPv6 addresses simultaneously
- class TNetAddr: public IRemoteAddr {
- public:
- class TError: public yexception {
- };
-
- TNetAddr();
- TNetAddr(TAutoPtr<IRemoteAddr> addr);
- TNetAddr(const char* hostPort, EIpVersion requireVersion = EIP_VERSION_ANY, EIpVersion preferVersion = EIP_VERSION_ANY);
- TNetAddr(TStringBuf host, int port, EIpVersion requireVersion = EIP_VERSION_ANY, EIpVersion preferVersion = EIP_VERSION_ANY);
- TNetAddr(const TNetworkAddress& na, EIpVersion requireVersion = EIP_VERSION_ANY, EIpVersion preferVersion = EIP_VERSION_ANY);
- TNetAddr(const TNetworkAddress& na, const TAddrInfo& ai);
-
- bool operator==(const TNetAddr&) const;
- bool operator!=(const TNetAddr& other) const {
- return !(*this == other);
- }
- inline explicit operator bool() const noexcept {
- return !!Ptr;
- }
-
- const sockaddr* Addr() const override;
- socklen_t Len() const override;
-
- bool IsIpv4() const;
- bool IsIpv6() const;
- int GetPort() const;
-
- private:
- TAtomicSharedPtr<IRemoteAddr> Ptr;
- };
-
- using TSockAddrInVector = TVector<TNetAddr>;
-
- struct TNetAddrHostPortHash {
- inline size_t operator()(const TNetAddr& a) const {
- const sockaddr* s = a.Addr();
- const sockaddr_in* const sa = reinterpret_cast<const sockaddr_in*>(s);
- const sockaddr_in6* const sa6 = reinterpret_cast<const sockaddr_in6*>(s);
-
- switch (s->sa_family) {
- case AF_INET:
+ const char* ToCString(EIpVersion);
+ int ToAddrFamily(EIpVersion);
+
+ /// Hold referenced pointer to address description structure (ex. sockaddr_storage)
+ /// It's make possible to work with IPv4 / IPv6 addresses simultaneously
+ class TNetAddr: public IRemoteAddr {
+ public:
+ class TError: public yexception {
+ };
+
+ TNetAddr();
+ TNetAddr(TAutoPtr<IRemoteAddr> addr);
+ TNetAddr(const char* hostPort, EIpVersion requireVersion = EIP_VERSION_ANY, EIpVersion preferVersion = EIP_VERSION_ANY);
+ TNetAddr(TStringBuf host, int port, EIpVersion requireVersion = EIP_VERSION_ANY, EIpVersion preferVersion = EIP_VERSION_ANY);
+ TNetAddr(const TNetworkAddress& na, EIpVersion requireVersion = EIP_VERSION_ANY, EIpVersion preferVersion = EIP_VERSION_ANY);
+ TNetAddr(const TNetworkAddress& na, const TAddrInfo& ai);
+
+ bool operator==(const TNetAddr&) const;
+ bool operator!=(const TNetAddr& other) const {
+ return !(*this == other);
+ }
+ inline explicit operator bool() const noexcept {
+ return !!Ptr;
+ }
+
+ const sockaddr* Addr() const override;
+ socklen_t Len() const override;
+
+ bool IsIpv4() const;
+ bool IsIpv6() const;
+ int GetPort() const;
+
+ private:
+ TAtomicSharedPtr<IRemoteAddr> Ptr;
+ };
+
+ using TSockAddrInVector = TVector<TNetAddr>;
+
+ struct TNetAddrHostPortHash {
+ inline size_t operator()(const TNetAddr& a) const {
+ const sockaddr* s = a.Addr();
+ const sockaddr_in* const sa = reinterpret_cast<const sockaddr_in*>(s);
+ const sockaddr_in6* const sa6 = reinterpret_cast<const sockaddr_in6*>(s);
+
+ switch (s->sa_family) {
+ case AF_INET:
return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa->sin_addr), sizeof(sa->sin_addr))), IntHashImpl(sa->sin_port));
- case AF_INET6:
+ case AF_INET6:
return CombineHashes<size_t>(ComputeHash(TStringBuf(reinterpret_cast<const char*>(&sa6->sin6_addr), sizeof(sa6->sin6_addr))), IntHashImpl(sa6->sin6_port));
- }
+ }
return ComputeHash(TStringBuf(reinterpret_cast<const char*>(s), a.Len()));
}
- };
+ };
-}
+}
diff --git a/library/cpp/messagebus/config/session_config.cpp b/library/cpp/messagebus/config/session_config.cpp
index fbbbb106c9..31c7dd29f2 100644
--- a/library/cpp/messagebus/config/session_config.cpp
+++ b/library/cpp/messagebus/config/session_config.cpp
@@ -13,8 +13,8 @@ TBusSessionConfig::TSecret::TSecret()
TBusSessionConfig::TBusSessionConfig()
: BUS_SESSION_CONFIG_MAP(STRUCT_FIELD_INIT, COMMA)
-{
-}
+{
+}
TString TBusSessionConfig::PrintToString() const {
TStringStream ss;
@@ -40,10 +40,10 @@ static int ParseToSForMessageBus(const char* option) {
return tos;
}
-template <class T>
-static T ParseWithKmgSuffixT(const char* option) {
+template <class T>
+static T ParseWithKmgSuffixT(const char* option) {
TStringBuf str(option);
- T multiplier = 1;
+ T multiplier = 1;
if (str.EndsWith('k')) {
multiplier = 1024;
str = str.Head(str.size() - 1);
@@ -54,104 +54,104 @@ static T ParseWithKmgSuffixT(const char* option) {
multiplier = 1024 * 1024 * 1024;
str = str.Head(str.size() - 1);
}
- return FromString<T>(str) * multiplier;
-}
-
-static ui64 ParseWithKmgSuffix(const char* option) {
- return ParseWithKmgSuffixT<ui64>(option);
-}
-
-static i64 ParseWithKmgSuffixS(const char* option) {
- return ParseWithKmgSuffixT<i64>(option);
+ return FromString<T>(str) * multiplier;
}
+static ui64 ParseWithKmgSuffix(const char* option) {
+ return ParseWithKmgSuffixT<ui64>(option);
+}
+
+static i64 ParseWithKmgSuffixS(const char* option) {
+ return ParseWithKmgSuffixT<i64>(option);
+}
+
void TBusSessionConfig::ConfigureLastGetopt(NLastGetopt::TOpts& opts,
const TString& prefix) {
opts.AddLongOption(prefix + "total-timeout")
- .RequiredArgument("MILLISECONDS")
- .DefaultValue(ToString(TotalTimeout))
+ .RequiredArgument("MILLISECONDS")
+ .DefaultValue(ToString(TotalTimeout))
.StoreMappedResultT<const char*>(&TotalTimeout,
&ParseDurationForMessageBus);
opts.AddLongOption(prefix + "connect-timeout")
- .RequiredArgument("MILLISECONDS")
- .DefaultValue(ToString(ConnectTimeout))
+ .RequiredArgument("MILLISECONDS")
+ .DefaultValue(ToString(ConnectTimeout))
.StoreMappedResultT<const char*>(&ConnectTimeout,
&ParseDurationForMessageBus);
opts.AddLongOption(prefix + "send-timeout")
- .RequiredArgument("MILLISECONDS")
- .DefaultValue(ToString(SendTimeout))
+ .RequiredArgument("MILLISECONDS")
+ .DefaultValue(ToString(SendTimeout))
.StoreMappedResultT<const char*>(&SendTimeout,
&ParseDurationForMessageBus);
opts.AddLongOption(prefix + "send-threshold")
- .RequiredArgument("BYTES")
- .DefaultValue(ToString(SendThreshold))
+ .RequiredArgument("BYTES")
+ .DefaultValue(ToString(SendThreshold))
.StoreMappedResultT<const char*>(&SendThreshold, &ParseWithKmgSuffix);
opts.AddLongOption(prefix + "max-in-flight")
- .RequiredArgument("COUNT")
- .DefaultValue(ToString(MaxInFlight))
+ .RequiredArgument("COUNT")
+ .DefaultValue(ToString(MaxInFlight))
.StoreMappedResultT<const char*>(&MaxInFlight, &ParseWithKmgSuffix);
opts.AddLongOption(prefix + "max-in-flight-by-size")
- .RequiredArgument("BYTES")
- .DefaultValue(
- ToString(MaxInFlightBySize))
- .StoreMappedResultT<const char*>(&MaxInFlightBySize, &ParseWithKmgSuffixS);
+ .RequiredArgument("BYTES")
+ .DefaultValue(
+ ToString(MaxInFlightBySize))
+ .StoreMappedResultT<const char*>(&MaxInFlightBySize, &ParseWithKmgSuffixS);
opts.AddLongOption(prefix + "per-con-max-in-flight")
- .RequiredArgument("COUNT")
- .DefaultValue(ToString(PerConnectionMaxInFlight))
+ .RequiredArgument("COUNT")
+ .DefaultValue(ToString(PerConnectionMaxInFlight))
.StoreMappedResultT<const char*>(&PerConnectionMaxInFlight,
&ParseWithKmgSuffix);
opts.AddLongOption(prefix + "per-con-max-in-flight-by-size")
- .RequiredArgument("BYTES")
- .DefaultValue(
- ToString(PerConnectionMaxInFlightBySize))
+ .RequiredArgument("BYTES")
+ .DefaultValue(
+ ToString(PerConnectionMaxInFlightBySize))
.StoreMappedResultT<const char*>(&PerConnectionMaxInFlightBySize,
&ParseWithKmgSuffix);
opts.AddLongOption(prefix + "default-buffer-size")
- .RequiredArgument("BYTES")
- .DefaultValue(ToString(DefaultBufferSize))
+ .RequiredArgument("BYTES")
+ .DefaultValue(ToString(DefaultBufferSize))
.StoreMappedResultT<const char*>(&DefaultBufferSize,
&ParseWithKmgSuffix);
opts.AddLongOption(prefix + "max-buffer-size")
- .RequiredArgument("BYTES")
- .DefaultValue(ToString(MaxBufferSize))
+ .RequiredArgument("BYTES")
+ .DefaultValue(ToString(MaxBufferSize))
.StoreMappedResultT<const char*>(&MaxBufferSize, &ParseWithKmgSuffix);
opts.AddLongOption(prefix + "max-message-size")
- .RequiredArgument("BYTES")
- .DefaultValue(ToString(MaxMessageSize))
+ .RequiredArgument("BYTES")
+ .DefaultValue(ToString(MaxMessageSize))
.StoreMappedResultT<const char*>(&MaxMessageSize, &ParseWithKmgSuffix);
opts.AddLongOption(prefix + "socket-recv-buffer-size")
- .RequiredArgument("BYTES")
- .DefaultValue(ToString(SocketRecvBufferSize))
+ .RequiredArgument("BYTES")
+ .DefaultValue(ToString(SocketRecvBufferSize))
.StoreMappedResultT<const char*>(&SocketRecvBufferSize,
&ParseWithKmgSuffix);
opts.AddLongOption(prefix + "socket-send-buffer-size")
- .RequiredArgument("BYTES")
- .DefaultValue(ToString(SocketSendBufferSize))
+ .RequiredArgument("BYTES")
+ .DefaultValue(ToString(SocketSendBufferSize))
.StoreMappedResultT<const char*>(&SocketSendBufferSize,
&ParseWithKmgSuffix);
opts.AddLongOption(prefix + "socket-tos")
.RequiredArgument("[0x00, 0xFF]")
- .StoreMappedResultT<const char*>(&SocketToS, &ParseToSForMessageBus);
- ;
+ .StoreMappedResultT<const char*>(&SocketToS, &ParseToSForMessageBus);
+ ;
opts.AddLongOption(prefix + "tcp-cork")
- .RequiredArgument("BOOL")
- .DefaultValue(ToString(TcpCork))
+ .RequiredArgument("BOOL")
+ .DefaultValue(ToString(TcpCork))
.StoreResult(&TcpCork);
opts.AddLongOption(prefix + "cork")
- .RequiredArgument("SECONDS")
- .DefaultValue(
- ToString(Cork.Seconds()))
+ .RequiredArgument("SECONDS")
+ .DefaultValue(
+ ToString(Cork.Seconds()))
.StoreMappedResultT<const char*>(&Cork, &TDuration::Parse);
opts.AddLongOption(prefix + "on-message-in-pool")
- .RequiredArgument("BOOL")
- .DefaultValue(ToString(ExecuteOnMessageInWorkerPool))
+ .RequiredArgument("BOOL")
+ .DefaultValue(ToString(ExecuteOnMessageInWorkerPool))
.StoreResult(&ExecuteOnMessageInWorkerPool);
opts.AddLongOption(prefix + "on-reply-in-pool")
- .RequiredArgument("BOOL")
- .DefaultValue(ToString(ExecuteOnReplyInWorkerPool))
+ .RequiredArgument("BOOL")
+ .DefaultValue(ToString(ExecuteOnReplyInWorkerPool))
.StoreResult(&ExecuteOnReplyInWorkerPool);
}
diff --git a/library/cpp/messagebus/config/session_config.h b/library/cpp/messagebus/config/session_config.h
index 84753350a9..db17018bbc 100644
--- a/library/cpp/messagebus/config/session_config.h
+++ b/library/cpp/messagebus/config/session_config.h
@@ -8,58 +8,58 @@
#include <util/generic/string.h>
namespace NBus {
-#define BUS_SESSION_CONFIG_MAP(XX, comma) \
- XX(Name, TString, "") \
- comma \
- XX(NumRetries, int, 0) comma \
- XX(RetryInterval, int, 1000) comma \
- XX(ReconnectWhenIdle, bool, false) comma \
- XX(MaxInFlight, i64, 1000) comma \
- XX(PerConnectionMaxInFlight, unsigned, 0) comma \
- XX(PerConnectionMaxInFlightBySize, unsigned, 0) comma \
- XX(MaxInFlightBySize, i64, -1) comma \
- XX(TotalTimeout, i64, 0) comma \
- XX(SendTimeout, i64, 0) comma \
- XX(ConnectTimeout, i64, 0) comma \
- XX(DefaultBufferSize, size_t, 10 * 1024) comma \
- XX(MaxBufferSize, size_t, 1024 * 1024) comma \
- XX(SocketRecvBufferSize, unsigned, 0) comma \
- XX(SocketSendBufferSize, unsigned, 0) comma \
- XX(SocketToS, int, -1) comma \
- XX(SendThreshold, size_t, 10 * 1024) comma \
- XX(Cork, TDuration, TDuration::Zero()) comma \
- XX(MaxMessageSize, unsigned, 26 << 20) comma \
- XX(TcpNoDelay, bool, false) comma \
- XX(TcpCork, bool, false) comma \
- XX(ExecuteOnMessageInWorkerPool, bool, true) comma \
- XX(ExecuteOnReplyInWorkerPool, bool, true) comma \
- XX(ReusePort, bool, false) comma \
- XX(ListenPort, unsigned, 0) /* TODO: server only */
+#define BUS_SESSION_CONFIG_MAP(XX, comma) \
+ XX(Name, TString, "") \
+ comma \
+ XX(NumRetries, int, 0) comma \
+ XX(RetryInterval, int, 1000) comma \
+ XX(ReconnectWhenIdle, bool, false) comma \
+ XX(MaxInFlight, i64, 1000) comma \
+ XX(PerConnectionMaxInFlight, unsigned, 0) comma \
+ XX(PerConnectionMaxInFlightBySize, unsigned, 0) comma \
+ XX(MaxInFlightBySize, i64, -1) comma \
+ XX(TotalTimeout, i64, 0) comma \
+ XX(SendTimeout, i64, 0) comma \
+ XX(ConnectTimeout, i64, 0) comma \
+ XX(DefaultBufferSize, size_t, 10 * 1024) comma \
+ XX(MaxBufferSize, size_t, 1024 * 1024) comma \
+ XX(SocketRecvBufferSize, unsigned, 0) comma \
+ XX(SocketSendBufferSize, unsigned, 0) comma \
+ XX(SocketToS, int, -1) comma \
+ XX(SendThreshold, size_t, 10 * 1024) comma \
+ XX(Cork, TDuration, TDuration::Zero()) comma \
+ XX(MaxMessageSize, unsigned, 26 << 20) comma \
+ XX(TcpNoDelay, bool, false) comma \
+ XX(TcpCork, bool, false) comma \
+ XX(ExecuteOnMessageInWorkerPool, bool, true) comma \
+ XX(ExecuteOnReplyInWorkerPool, bool, true) comma \
+ XX(ReusePort, bool, false) comma \
+ XX(ListenPort, unsigned, 0) /* TODO: server only */
- ////////////////////////////////////////////////////////////////////
- /// \brief Configuration for client and server session
- struct TBusSessionConfig {
- BUS_SESSION_CONFIG_MAP(STRUCT_FIELD_GEN, )
+ ////////////////////////////////////////////////////////////////////
+ /// \brief Configuration for client and server session
+ struct TBusSessionConfig {
+ BUS_SESSION_CONFIG_MAP(STRUCT_FIELD_GEN, )
- struct TSecret {
- TDuration TimeoutPeriod;
- TDuration StatusFlushPeriod;
+ struct TSecret {
+ TDuration TimeoutPeriod;
+ TDuration StatusFlushPeriod;
- TSecret();
- };
+ TSecret();
+ };
- // secret options are available, but you shouldn't probably use them
- TSecret Secret;
+ // secret options are available, but you shouldn't probably use them
+ TSecret Secret;
- /// initialized with default settings
- TBusSessionConfig();
+ /// initialized with default settings
+ TBusSessionConfig();
- TString PrintToString() const;
+ TString PrintToString() const;
- void ConfigureLastGetopt(NLastGetopt::TOpts&, const TString& prefix = "mb-");
- };
+ void ConfigureLastGetopt(NLastGetopt::TOpts&, const TString& prefix = "mb-");
+ };
- using TBusClientSessionConfig = TBusSessionConfig;
- using TBusServerSessionConfig = TBusSessionConfig;
+ using TBusClientSessionConfig = TBusSessionConfig;
+ using TBusServerSessionConfig = TBusSessionConfig;
} // NBus