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/config | |
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/config')
-rw-r--r-- | library/cpp/messagebus/config/codegen.h | 20 | ||||
-rw-r--r-- | library/cpp/messagebus/config/defs.h | 56 | ||||
-rw-r--r-- | library/cpp/messagebus/config/netaddr.cpp | 34 | ||||
-rw-r--r-- | library/cpp/messagebus/config/netaddr.h | 4 | ||||
-rw-r--r-- | library/cpp/messagebus/config/session_config.cpp | 70 | ||||
-rw-r--r-- | library/cpp/messagebus/config/session_config.h | 34 |
6 files changed, 109 insertions, 109 deletions
diff --git a/library/cpp/messagebus/config/codegen.h b/library/cpp/messagebus/config/codegen.h index 97ddada0055..5508fefc925 100644 --- a/library/cpp/messagebus/config/codegen.h +++ b/library/cpp/messagebus/config/codegen.h @@ -1,10 +1,10 @@ -#pragma once - -#define COMMA , - -#define STRUCT_FIELD_GEN(name, type, ...) type name; - -#define STRUCT_FIELD_INIT(name, type, defa) name(defa) -#define STRUCT_FIELD_INIT_DEFAULT(name, type, ...) name() - -#define STRUCT_FIELD_PRINT(name, ...) ss << #name << "=" << name << "\n"; +#pragma once + +#define COMMA , + +#define STRUCT_FIELD_GEN(name, type, ...) type name; + +#define STRUCT_FIELD_INIT(name, type, defa) name(defa) +#define STRUCT_FIELD_INIT_DEFAULT(name, type, ...) name() + +#define STRUCT_FIELD_PRINT(name, ...) ss << #name << "=" << name << "\n"; diff --git a/library/cpp/messagebus/config/defs.h b/library/cpp/messagebus/config/defs.h index 92b1df99698..10820f83fd9 100644 --- a/library/cpp/messagebus/config/defs.h +++ b/library/cpp/messagebus/config/defs.h @@ -1,23 +1,23 @@ -#pragma once +#pragma once // unique tag to fix pragma once gcc glueing: ./library/cpp/messagebus/defs.h - + #include "codegen.h" #include "netaddr.h" #include <library/cpp/deprecated/enum_codegen/enum_codegen.h> -#include <util/generic/list.h> +#include <util/generic/list.h> #include <utility> - -// For historical reasons TCrawlerModule need to access -// APIs that should be private. -class TCrawlerModule; - -struct TDebugReceiverHandler; - -namespace NBus { + +// For historical reasons TCrawlerModule need to access +// APIs that should be private. +class TCrawlerModule; + +struct TDebugReceiverHandler; + +namespace NBus { namespace NPrivate { class TAcceptor; struct TBusSessionImpl; @@ -27,15 +27,15 @@ namespace NBus { class TRemoteServerConnection; class TRemoteClientConnection; class TBusSyncSourceSessionImpl; - + struct TBusMessagePtrAndHeader; - + struct TSessionDumpStatus; - + struct TClientRequestImpl; - + } - + class TBusSession; struct TBusServerSession; struct TBusClientSession; @@ -47,36 +47,36 @@ namespace NBus { struct TBusQueueConfig; struct TBusSessionConfig; struct TBusHeader; - + class IThreadHandler; - + using TBusKey = ui64; using TBusMessageList = TList<TBusMessage*>; using TBusKeyVec = TVector<std::pair<TBusKey, TBusKey>>; - + using TBusMessageQueuePtr = TIntrusivePtr<TBusMessageQueue>; - + class TBusModule; - + using TBusData = TString; using TBusService = const char*; - + #define YBUS_KEYMIN TBusKey(0L) #define YBUS_KEYMAX TBusKey(-1L) #define YBUS_KEYLOCAL TBusKey(7L) -#define YBUS_KEYINVALID TBusKey(99999999L) - +#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; } #define YBUS_VERSION 0 - + #define YBUS_INFINITE (1u << 30u) - + #define YBUS_STATUS_BASIC 0x0000 #define YBUS_STATUS_CONNS 0x0001 -#define YBUS_STATUS_INFLIGHT 0x0002 - +#define YBUS_STATUS_INFLIGHT 0x0002 + } diff --git a/library/cpp/messagebus/config/netaddr.cpp b/library/cpp/messagebus/config/netaddr.cpp index 962ac538e27..3c6311ab157 100644 --- a/library/cpp/messagebus/config/netaddr.cpp +++ b/library/cpp/messagebus/config/netaddr.cpp @@ -1,7 +1,7 @@ #include "netaddr.h" -#include <util/network/address.h> - +#include <util/network/address.h> + #include <cstdlib> namespace NBus { @@ -15,8 +15,8 @@ namespace NBus { return "EIP_VERSION_6"; } Y_FAIL(); - } - + } + int ToAddrFamily(EIpVersion ipVersion) { switch (ipVersion) { case EIP_VERSION_ANY: @@ -83,8 +83,8 @@ namespace NBus { 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) { @@ -95,9 +95,9 @@ namespace NBus { addr.Reset(new TNetworkAddressRef(na, &*it)); } } - } + } return addr; - } + } TAutoPtr<IRemoteAddr> MakeAddress(TStringBuf host, int port, EIpVersion requireVersion, EIpVersion preferVersion) { TString hostString(host); TNetworkAddress na(hostString, port); @@ -136,17 +136,17 @@ namespace NBus { if (!Ptr) { ythrow TNetAddr::TError() << "cannot resolve into " << Describe(requireVersion); } - } - + } + TNetAddr::TNetAddr(const TNetworkAddress& na, const TAddrInfo& ai) : Ptr(new TNetworkAddressRef(na, ai)) { } - + const sockaddr* TNetAddr::Addr() const { return Ptr->Addr(); } - + socklen_t TNetAddr::Len() const { return Ptr->Len(); } @@ -169,14 +169,14 @@ namespace NBus { 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); } - -} - + +} + template <> void Out<NBus::TNetAddr>(IOutputStream& out, const NBus::TNetAddr& addr) { Out<NAddr::IRemoteAddr>(out, addr); diff --git a/library/cpp/messagebus/config/netaddr.h b/library/cpp/messagebus/config/netaddr.h index b79c0cc3551..3f8c80cde55 100644 --- a/library/cpp/messagebus/config/netaddr.h +++ b/library/cpp/messagebus/config/netaddr.h @@ -29,7 +29,7 @@ namespace NBus { 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 { @@ -62,7 +62,7 @@ namespace NBus { private: TAtomicSharedPtr<IRemoteAddr> Ptr; }; - + using TSockAddrInVector = TVector<TNetAddr>; struct TNetAddrHostPortHash { diff --git a/library/cpp/messagebus/config/session_config.cpp b/library/cpp/messagebus/config/session_config.cpp index fbbbb106c9d..fefd61c8f42 100644 --- a/library/cpp/messagebus/config/session_config.cpp +++ b/library/cpp/messagebus/config/session_config.cpp @@ -1,31 +1,31 @@ -#include "session_config.h" - +#include "session_config.h" + #include <util/generic/strbuf.h> #include <util/string/hex.h> - -using namespace NBus; - -TBusSessionConfig::TSecret::TSecret() - : TimeoutPeriod(TDuration::Seconds(1)) - , StatusFlushPeriod(TDuration::MilliSeconds(400)) -{ -} - -TBusSessionConfig::TBusSessionConfig() - : BUS_SESSION_CONFIG_MAP(STRUCT_FIELD_INIT, COMMA) + +using namespace NBus; + +TBusSessionConfig::TSecret::TSecret() + : TimeoutPeriod(TDuration::Seconds(1)) + , StatusFlushPeriod(TDuration::MilliSeconds(400)) +{ +} + +TBusSessionConfig::TBusSessionConfig() + : BUS_SESSION_CONFIG_MAP(STRUCT_FIELD_INIT, COMMA) { } - + TString TBusSessionConfig::PrintToString() const { - TStringStream ss; - BUS_SESSION_CONFIG_MAP(STRUCT_FIELD_PRINT, ) - return ss.Str(); -} - -static int ParseDurationForMessageBus(const char* option) { - return TDuration::Parse(option).MilliSeconds(); -} - + TStringStream ss; + BUS_SESSION_CONFIG_MAP(STRUCT_FIELD_PRINT, ) + return ss.Str(); +} + +static int ParseDurationForMessageBus(const char* option) { + return TDuration::Parse(option).MilliSeconds(); +} + static int ParseToSForMessageBus(const char* option) { int tos; TStringBuf str(option); @@ -42,21 +42,21 @@ static int ParseToSForMessageBus(const char* option) { template <class T> static T ParseWithKmgSuffixT(const char* option) { - TStringBuf str(option); + TStringBuf str(option); T multiplier = 1; if (str.EndsWith('k')) { - multiplier = 1024; + multiplier = 1024; str = str.Head(str.size() - 1); } else if (str.EndsWith('m')) { - multiplier = 1024 * 1024; + multiplier = 1024 * 1024; str = str.Head(str.size() - 1); } else if (str.EndsWith('g')) { - multiplier = 1024 * 1024 * 1024; + 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); } @@ -90,7 +90,7 @@ void TBusSessionConfig::ConfigureLastGetopt(NLastGetopt::TOpts& opts, opts.AddLongOption(prefix + "max-in-flight") .RequiredArgument("COUNT") .DefaultValue(ToString(MaxInFlight)) - .StoreMappedResultT<const char*>(&MaxInFlight, &ParseWithKmgSuffix); + .StoreMappedResultT<const char*>(&MaxInFlight, &ParseWithKmgSuffix); opts.AddLongOption(prefix + "max-in-flight-by-size") .RequiredArgument("BYTES") .DefaultValue( @@ -116,7 +116,7 @@ void TBusSessionConfig::ConfigureLastGetopt(NLastGetopt::TOpts& opts, opts.AddLongOption(prefix + "max-buffer-size") .RequiredArgument("BYTES") .DefaultValue(ToString(MaxBufferSize)) - .StoreMappedResultT<const char*>(&MaxBufferSize, &ParseWithKmgSuffix); + .StoreMappedResultT<const char*>(&MaxBufferSize, &ParseWithKmgSuffix); opts.AddLongOption(prefix + "max-message-size") .RequiredArgument("BYTES") .DefaultValue(ToString(MaxMessageSize)) @@ -149,9 +149,9 @@ void TBusSessionConfig::ConfigureLastGetopt(NLastGetopt::TOpts& opts, opts.AddLongOption(prefix + "on-message-in-pool") .RequiredArgument("BOOL") .DefaultValue(ToString(ExecuteOnMessageInWorkerPool)) - .StoreResult(&ExecuteOnMessageInWorkerPool); + .StoreResult(&ExecuteOnMessageInWorkerPool); opts.AddLongOption(prefix + "on-reply-in-pool") .RequiredArgument("BOOL") .DefaultValue(ToString(ExecuteOnReplyInWorkerPool)) - .StoreResult(&ExecuteOnReplyInWorkerPool); -} + .StoreResult(&ExecuteOnReplyInWorkerPool); +} diff --git a/library/cpp/messagebus/config/session_config.h b/library/cpp/messagebus/config/session_config.h index 84753350a90..7b02dbcd4e8 100644 --- a/library/cpp/messagebus/config/session_config.h +++ b/library/cpp/messagebus/config/session_config.h @@ -1,13 +1,13 @@ -#pragma once - +#pragma once + #include "codegen.h" -#include "defs.h" - +#include "defs.h" + #include <library/cpp/getopt/last_getopt.h> - + #include <util/generic/string.h> - -namespace NBus { + +namespace NBus { #define BUS_SESSION_CONFIG_MAP(XX, comma) \ XX(Name, TString, "") \ comma \ @@ -35,31 +35,31 @@ namespace NBus { 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, ) - + struct TSecret { TDuration TimeoutPeriod; TDuration StatusFlushPeriod; - + TSecret(); }; - + // secret options are available, but you shouldn't probably use them TSecret Secret; - + /// initialized with default settings TBusSessionConfig(); - + TString PrintToString() const; - + void ConfigureLastGetopt(NLastGetopt::TOpts&, const TString& prefix = "mb-"); }; - + using TBusClientSessionConfig = TBusSessionConfig; using TBusServerSessionConfig = TBusSessionConfig; - -} // NBus + +} // NBus |