#pragma once #include #include #include #include #include #include #include #include #include "poller_tcp.h" #include "logging.h" #include "event_filter.h" #include namespace NActors { enum class EEncryptionMode { DISABLED, // no encryption is required at all OPTIONAL, // encryption is enabled when supported by both peers REQUIRED, // encryption is mandatory }; struct TInterconnectSettings { TDuration Handshake; TDuration DeadPeer; TDuration CloseOnIdle; ui32 SendBufferDieLimitInMB = 0; ui64 OutputBuffersTotalSizeLimitInMB = 0; ui32 TotalInflightAmountOfData = 0; bool MergePerPeerCounters = false; bool MergePerDataCenterCounters = false; ui32 TCPSocketBufferSize = 0; TDuration PingPeriod = TDuration::Seconds(3); TDuration ForceConfirmPeriod = TDuration::Seconds(1); TDuration LostConnection; TDuration BatchPeriod; bool BindOnAllAddresses = true; EEncryptionMode EncryptionMode = EEncryptionMode::DISABLED; bool TlsAuthOnly = false; TString Certificate; // certificate data in PEM format TString PrivateKey; // private key for the certificate in PEM format TString CaFilePath; // path to certificate authority file TString CipherList; // encryption algorithms TDuration MessagePendingTimeout = TDuration::Seconds(1); // timeout for which messages are queued while in PendingConnection state ui64 MessagePendingSize = Max(); // size of the queue ui32 MaxSerializedEventSize = NActors::EventMaxByteSize; ui32 GetSendBufferSize() const { ui32 res = 512 * 1024; // 512 kb is the default value for send buffer if (TCPSocketBufferSize) { res = TCPSocketBufferSize; } return res; } }; struct TChannelSettings { ui16 Weight; }; typedef TMap TChannelsConfig; using TRegisterMonPageCallback = std::function; using TInitWhiteboardCallback = std::function; using TUpdateWhiteboardCallback = std::function; struct TInterconnectProxyCommon : TAtomicRefCount { TActorId NameserviceId; NMonitoring::TDynamicCounterPtr MonCounters; std::shared_ptr Metrics; TChannelsConfig ChannelsConfig; TInterconnectSettings Settings; TRegisterMonPageCallback RegisterMonPage; TActorId DestructorId; std::shared_ptr> DestructorQueueSize; TAtomicBase MaxDestructorQueueSize = 1024 * 1024 * 1024; TString ClusterUUID; TVector AcceptUUID; ui64 StartTime = GetCycleCountFast(); TString TechnicalSelfHostName; TInitWhiteboardCallback InitWhiteboard; TUpdateWhiteboardCallback UpdateWhiteboard; ui32 HandshakeBallastSize = 0; TAtomic StartedSessionKiller = 0; TScopeId LocalScopeId; std::shared_ptr EventFilter; TString Cookie; // unique random identifier of a node instance (generated randomly at every start) std::unordered_map ChannelName; struct TVersionInfo { TString Tag; // version tag for this node TSet AcceptedTags; // we accept all enlisted version tags of peer nodes, but no others; empty = accept all }; TMaybe VersionInfo; using TPtr = TIntrusivePtr; }; }