diff options
author | Sergey Polovko <sergey@polovko.me> | 2022-02-10 16:47:02 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:02 +0300 |
commit | 3e0b762a82514bac89c1dd6ea7211e381d8aa248 (patch) | |
tree | c2d1b379ecaf05ca8f11ed0b5da9d1a950e6e554 /library/cpp/actors/http | |
parent | ab3783171cc30e262243a0227c86118f7080c896 (diff) | |
download | ydb-3e0b762a82514bac89c1dd6ea7211e381d8aa248.tar.gz |
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/actors/http')
-rw-r--r-- | library/cpp/actors/http/http_cache.cpp | 4 | ||||
-rw-r--r-- | library/cpp/actors/http/http_cache.h | 2 | ||||
-rw-r--r-- | library/cpp/actors/http/http_proxy.cpp | 26 | ||||
-rw-r--r-- | library/cpp/actors/http/http_proxy.h | 34 | ||||
-rw-r--r-- | library/cpp/actors/http/http_proxy_acceptor.cpp | 16 | ||||
-rw-r--r-- | library/cpp/actors/http/http_proxy_outgoing.cpp | 14 | ||||
-rw-r--r-- | library/cpp/actors/http/http_ut.cpp | 24 | ||||
-rw-r--r-- | library/cpp/actors/http/ya.make | 2 |
8 files changed, 61 insertions, 61 deletions
diff --git a/library/cpp/actors/http/http_cache.cpp b/library/cpp/actors/http/http_cache.cpp index 27c4eeb6f3..834fe47b73 100644 --- a/library/cpp/actors/http/http_cache.cpp +++ b/library/cpp/actors/http/http_cache.cpp @@ -16,7 +16,7 @@ namespace NHttp { class THttpOutgoingCacheActor : public NActors::TActorBootstrapped<THttpOutgoingCacheActor>, THttpConfig { public: using TBase = NActors::TActorBootstrapped<THttpOutgoingCacheActor>; - NActors::TActorId HttpProxyId; + NActors::TActorId HttpProxyId; TGetCachePolicy GetCachePolicy; static constexpr TDuration RefreshTimeout = TDuration::Seconds(1); @@ -584,7 +584,7 @@ TCachePolicy GetDefaultCachePolicy(const THttpRequest* request, const TCachePoli return policy; } -NActors::IActor* CreateHttpCache(const NActors::TActorId& httpProxyId, TGetCachePolicy cachePolicy) { +NActors::IActor* CreateHttpCache(const NActors::TActorId& httpProxyId, TGetCachePolicy cachePolicy) { return new THttpOutgoingCacheActor(httpProxyId, std::move(cachePolicy)); } diff --git a/library/cpp/actors/http/http_cache.h b/library/cpp/actors/http/http_cache.h index ac38bdcac8..313c7bd266 100644 --- a/library/cpp/actors/http/http_cache.h +++ b/library/cpp/actors/http/http_cache.h @@ -19,7 +19,7 @@ struct TCachePolicy { using TGetCachePolicy = std::function<TCachePolicy(const THttpRequest*)>; -NActors::IActor* CreateHttpCache(const NActors::TActorId& httpProxyId, TGetCachePolicy cachePolicy); +NActors::IActor* CreateHttpCache(const NActors::TActorId& httpProxyId, TGetCachePolicy cachePolicy); NActors::IActor* CreateOutgoingHttpCache(const NActors::TActorId& httpProxyId, TGetCachePolicy cachePolicy); NActors::IActor* CreateIncomingHttpCache(const NActors::TActorId& httpProxyId, TGetCachePolicy cachePolicy); TCachePolicy GetDefaultCachePolicy(const THttpRequest* request, const TCachePolicy& policy = TCachePolicy()); diff --git a/library/cpp/actors/http/http_proxy.cpp b/library/cpp/actors/http/http_proxy.cpp index 36c6855d93..3a466006cd 100644 --- a/library/cpp/actors/http/http_proxy.cpp +++ b/library/cpp/actors/http/http_proxy.cpp @@ -1,5 +1,5 @@ #include <library/cpp/actors/core/events.h> -#include <library/cpp/monlib/metrics/metric_registry.h> +#include <library/cpp/monlib/metrics/metric_registry.h> #include "http_proxy.h" namespace NHttp { @@ -8,7 +8,7 @@ class THttpProxy : public NActors::TActorBootstrapped<THttpProxy>, public THttpC public: IActor* AddListeningPort(TEvHttpProxy::TEvAddListeningPort::TPtr event, const NActors::TActorContext& ctx) { IActor* listeningSocket = CreateHttpAcceptorActor(ctx.SelfID, Poller); - TActorId acceptorId = ctx.Register(listeningSocket); + TActorId acceptorId = ctx.Register(listeningSocket); ctx.Send(event->Forward(acceptorId)); Acceptors.emplace_back(acceptorId); return listeningSocket; @@ -16,7 +16,7 @@ public: IActor* AddOutgoingConnection(const TString& address, bool secure, const NActors::TActorContext& ctx) { IActor* connectionSocket = CreateOutgoingConnectionActor(ctx.SelfID, address, secure, Poller); - TActorId connectionId = ctx.Register(connectionSocket); + TActorId connectionId = ctx.Register(connectionSocket); Connections.emplace(connectionId); return connectionSocket; } @@ -26,7 +26,7 @@ public: Become(&THttpProxy::StateWork); } - THttpProxy(NMonitoring::TMetricRegistry& sensors) + THttpProxy(NMonitoring::TMetricRegistry& sensors) : Sensors(sensors) {} @@ -49,10 +49,10 @@ protected: void PassAway() override { Send(Poller, new NActors::TEvents::TEvPoisonPill()); - for (const NActors::TActorId& connection : Connections) { + for (const NActors::TActorId& connection : Connections) { Send(connection, new NActors::TEvents::TEvPoisonPill()); } - for (const NActors::TActorId& acceptor : Acceptors) { + for (const NActors::TActorId& acceptor : Acceptors) { Send(acceptor, new NActors::TEvents::TEvPoisonPill()); } NActors::TActorBootstrapped<THttpProxy>::PassAway(); @@ -60,7 +60,7 @@ protected: void Handle(TEvHttpProxy::TEvHttpIncomingRequest::TPtr event, const NActors::TActorContext& ctx) { TStringBuf url = event->Get()->Request->URL.Before('?'); - THashMap<TString, TActorId>::iterator it; + THashMap<TString, TActorId>::iterator it; while (!url.empty()) { it = Handlers.find(url); if (it != Handlers.end()) { @@ -204,8 +204,8 @@ protected: PassAway(); } - NActors::TActorId Poller; - TVector<TActorId> Acceptors; + NActors::TActorId Poller; + TVector<TActorId> Acceptors; struct THostEntry { TSockAddrInet6 Address; @@ -215,9 +215,9 @@ protected: static constexpr TDuration HostsTimeToLive = TDuration::Seconds(60); THashMap<TString, THostEntry> Hosts; - THashMap<TString, TActorId> Handlers; - THashSet<TActorId> Connections; // outgoing - NMonitoring::TMetricRegistry& Sensors; + THashMap<TString, TActorId> Handlers; + THashSet<TActorId> Connections; // outgoing + NMonitoring::TMetricRegistry& Sensors; }; TEvHttpProxy::TEvReportSensors* BuildOutgoingRequestSensors(const THttpOutgoingRequestPtr& request, const THttpIncomingResponsePtr& response) { @@ -240,7 +240,7 @@ TEvHttpProxy::TEvReportSensors* BuildIncomingRequestSensors(const THttpIncomingR ); } -NActors::IActor* CreateHttpProxy(NMonitoring::TMetricRegistry& sensors) { +NActors::IActor* CreateHttpProxy(NMonitoring::TMetricRegistry& sensors) { return new THttpProxy(sensors); } diff --git a/library/cpp/actors/http/http_proxy.h b/library/cpp/actors/http/http_proxy.h index afd0170997..97ea6fbd44 100644 --- a/library/cpp/actors/http/http_proxy.h +++ b/library/cpp/actors/http/http_proxy.h @@ -8,7 +8,7 @@ #include <library/cpp/actors/core/log.h> #include <library/cpp/actors/interconnect/poller_actor.h> #include <library/cpp/dns/cache.h> -#include <library/cpp/monlib/metrics/metric_registry.h> +#include <library/cpp/monlib/metrics/metric_registry.h> #include <util/generic/variant.h> #include "http.h" #include "http_proxy_ssl.h" @@ -25,7 +25,7 @@ struct TSocketDescriptor : NActors::TSharedDescriptor, THttpConfig { struct TEvHttpProxy { enum EEv { - EvAddListeningPort = EventSpaceBegin(NActors::TEvents::ES_HTTP), + EvAddListeningPort = EventSpaceBegin(NActors::TEvents::ES_HTTP), EvConfirmListen, EvRegisterHandler, EvHttpIncomingRequest, @@ -41,7 +41,7 @@ struct TEvHttpProxy { EvEnd }; - static_assert(EvEnd < EventSpaceEnd(NActors::TEvents::ES_HTTP), "ES_HTTP event space is too small."); + static_assert(EvEnd < EventSpaceEnd(NActors::TEvents::ES_HTTP), "ES_HTTP event space is too small."); struct TEvAddListeningPort : NActors::TEventLocal<TEvAddListeningPort, EvAddListeningPort> { TIpPort Port; @@ -71,9 +71,9 @@ struct TEvHttpProxy { struct TEvRegisterHandler : NActors::TEventLocal<TEvRegisterHandler, EvRegisterHandler> { TString Path; - TActorId Handler; + TActorId Handler; - TEvRegisterHandler(const TString& path, const TActorId& handler) + TEvRegisterHandler(const TString& path, const TActorId& handler) : Path(path) , Handler(handler) {} @@ -142,32 +142,32 @@ struct TEvHttpProxy { struct TEvHttpConnectionOpened : NActors::TEventLocal<TEvHttpConnectionOpened, EvHttpConnectionOpened> { TString PeerAddress; - TActorId ConnectionID; + TActorId ConnectionID; - TEvHttpConnectionOpened(const TString& peerAddress, const TActorId& connectionID) + TEvHttpConnectionOpened(const TString& peerAddress, const TActorId& connectionID) : PeerAddress(peerAddress) , ConnectionID(connectionID) {} }; struct TEvHttpConnectionClosed : NActors::TEventLocal<TEvHttpConnectionClosed, EvHttpConnectionClosed> { - TActorId ConnectionID; + TActorId ConnectionID; TDeque<THttpIncomingRequestPtr> RecycledRequests; - TEvHttpConnectionClosed(const TActorId& connectionID) + TEvHttpConnectionClosed(const TActorId& connectionID) : ConnectionID(connectionID) {} - TEvHttpConnectionClosed(const TActorId& connectionID, TDeque<THttpIncomingRequestPtr> recycledRequests) + TEvHttpConnectionClosed(const TActorId& connectionID, TDeque<THttpIncomingRequestPtr> recycledRequests) : ConnectionID(connectionID) , RecycledRequests(std::move(recycledRequests)) {} }; struct TEvHttpAcceptorClosed : NActors::TEventLocal<TEvHttpAcceptorClosed, EvHttpAcceptorClosed> { - TActorId ConnectionID; + TActorId ConnectionID; - TEvHttpAcceptorClosed(const TActorId& connectionID) + TEvHttpAcceptorClosed(const TActorId& connectionID) : ConnectionID(connectionID) {} }; @@ -218,16 +218,16 @@ struct TEvHttpProxy { }; struct TEndpointInfo { - TActorId Proxy; - TActorId Owner; + TActorId Proxy; + TActorId Owner; TString WorkerName; bool Secure; TSslHelpers::TSslHolder<SSL_CTX> SecureContext; }; -NActors::IActor* CreateHttpProxy(NMonitoring::TMetricRegistry& sensors); -NActors::IActor* CreateHttpAcceptorActor(const TActorId& owner, const TActorId& poller); -NActors::IActor* CreateOutgoingConnectionActor(const TActorId& owner, const TString& host, bool secure, const TActorId& poller); +NActors::IActor* CreateHttpProxy(NMonitoring::TMetricRegistry& sensors); +NActors::IActor* CreateHttpAcceptorActor(const TActorId& owner, const TActorId& poller); +NActors::IActor* CreateOutgoingConnectionActor(const TActorId& owner, const TString& host, bool secure, const TActorId& poller); NActors::IActor* CreateIncomingConnectionActor( const TEndpointInfo& endpoint, TIntrusivePtr<TSocketDescriptor> socket, diff --git a/library/cpp/actors/http/http_proxy_acceptor.cpp b/library/cpp/actors/http/http_proxy_acceptor.cpp index 9780541b71..95b07ffa84 100644 --- a/library/cpp/actors/http/http_proxy_acceptor.cpp +++ b/library/cpp/actors/http/http_proxy_acceptor.cpp @@ -7,15 +7,15 @@ namespace NHttp { class TAcceptorActor : public NActors::TActor<TAcceptorActor>, public THttpConfig { public: using TBase = NActors::TActor<TAcceptorActor>; - const TActorId Owner; - const TActorId Poller; + const TActorId Owner; + const TActorId Poller; TIntrusivePtr<TSocketDescriptor> Socket; NActors::TPollerToken::TPtr PollerToken; - THashSet<TActorId> Connections; + THashSet<TActorId> Connections; TDeque<THttpIncomingRequestPtr> RecycledRequests; TEndpointInfo Endpoint; - TAcceptorActor(const TActorId& owner, const TActorId& poller) + TAcceptorActor(const TActorId& owner, const TActorId& poller) : NActors::TActor<TAcceptorActor>(&TAcceptorActor::StateInit) , Owner(owner) , Poller(poller) @@ -77,12 +77,12 @@ protected: } } LOG_WARN_S(ctx, HttpLog, "Failed to listen on " << bindAddress.ToString() << " - retrying..."); - ctx.ExecutorThread.Schedule(TDuration::Seconds(1), event.Release()); + ctx.ExecutorThread.Schedule(TDuration::Seconds(1), event.Release()); } void Die(const NActors::TActorContext& ctx) override { ctx.Send(Owner, new TEvHttpProxy::TEvHttpAcceptorClosed(ctx.SelfID)); - for (const NActors::TActorId& connection : Connections) { + for (const NActors::TActorId& connection : Connections) { ctx.Send(connection, new NActors::TEvents::TEvPoisonPill()); } } @@ -104,7 +104,7 @@ protected: connectionSocket = CreateIncomingConnectionActor(Endpoint, socket, addr, std::move(RecycledRequests.front())); RecycledRequests.pop_front(); } - NActors::TActorId connectionId = ctx.Register(connectionSocket); + NActors::TActorId connectionId = ctx.Register(connectionSocket); ctx.Send(Poller, new NActors::TEvPollerRegister(socket, connectionId, connectionId)); Connections.emplace(connectionId); socket = new TSocketDescriptor(); @@ -128,7 +128,7 @@ protected: } }; -NActors::IActor* CreateHttpAcceptorActor(const TActorId& owner, const TActorId& poller) { +NActors::IActor* CreateHttpAcceptorActor(const TActorId& owner, const TActorId& poller) { return new TAcceptorActor(owner, poller); } diff --git a/library/cpp/actors/http/http_proxy_outgoing.cpp b/library/cpp/actors/http/http_proxy_outgoing.cpp index d9189dba8a..5bd4dd74b0 100644 --- a/library/cpp/actors/http/http_proxy_outgoing.cpp +++ b/library/cpp/actors/http/http_proxy_outgoing.cpp @@ -8,18 +8,18 @@ class TOutgoingConnectionActor : public NActors::TActor<TOutgoingConnectionActor public: using TBase = NActors::TActor<TOutgoingConnectionActor<TSocketImpl>>; using TSelf = TOutgoingConnectionActor<TSocketImpl>; - const TActorId Owner; - const TActorId Poller; + const TActorId Owner; + const TActorId Poller; SocketAddressType Address; TString Host; - TActorId RequestOwner; + TActorId RequestOwner; THttpOutgoingRequestPtr Request; THttpIncomingResponsePtr Response; TInstant LastActivity; TDuration ConnectionTimeout = CONNECTION_TIMEOUT; NActors::TPollerToken::TPtr PollerToken; - TOutgoingConnectionActor(const TActorId& owner, const TString& host, const TActorId& poller) + TOutgoingConnectionActor(const TActorId& owner, const TString& host, const TActorId& poller) : TBase(&TSelf::StateWaiting) , Owner(owner) , Poller(poller) @@ -38,7 +38,7 @@ public: void ReplyAndDie(const NActors::TActorContext& ctx) { LOG_DEBUG_S(ctx, HttpLog, "(#" << TSocketImpl::GetRawSocket() << "," << Address << ") -> (" << Response->Status << " " << Response->Message << ")"); ctx.Send(RequestOwner, new TEvHttpProxy::TEvHttpIncomingResponse(Request, Response)); - RequestOwner = TActorId(); + RequestOwner = TActorId(); THolder<TEvHttpProxy::TEvReportSensors> sensors(BuildOutgoingRequestSensors(Request, Response)); ctx.Send(Owner, sensors.Release()); LOG_DEBUG_S(ctx, HttpLog, "(#" << TSocketImpl::GetRawSocket() << "," << Address << ") connection closed"); @@ -49,7 +49,7 @@ public: LOG_ERROR_S(ctx, HttpLog, "(#" << TSocketImpl::GetRawSocket() << "," << Address << ") connection closed with error: " << error); if (RequestOwner) { ctx.Send(RequestOwner, new TEvHttpProxy::TEvHttpIncomingResponse(Request, Response, error)); - RequestOwner = TActorId(); + RequestOwner = TActorId(); THolder<TEvHttpProxy::TEvReportSensors> sensors(BuildOutgoingRequestSensors(Request, Response)); ctx.Send(Owner, sensors.Release()); Die(ctx); @@ -287,7 +287,7 @@ protected: } }; -NActors::IActor* CreateOutgoingConnectionActor(const TActorId& owner, const TString& host, bool secure, const TActorId& poller) { +NActors::IActor* CreateOutgoingConnectionActor(const TActorId& owner, const TString& host, bool secure, const TActorId& poller) { if (secure) { return new TOutgoingConnectionActor<TSecureSocketImpl>(owner, host, poller); } else { diff --git a/library/cpp/actors/http/http_ut.cpp b/library/cpp/actors/http/http_ut.cpp index 4c922f8d0f..b21ceb550f 100644 --- a/library/cpp/actors/http/http_ut.cpp +++ b/library/cpp/actors/http/http_ut.cpp @@ -180,17 +180,17 @@ Y_UNIT_TEST_SUITE(HttpProxy) { TIpPort port = portManager.GetTcpPort(); TAutoPtr<NActors::IEventHandle> handle; actorSystem.Initialize(); - NMonitoring::TMetricRegistry sensors; + NMonitoring::TMetricRegistry sensors; NActors::IActor* proxy = NHttp::CreateHttpProxy(sensors); - NActors::TActorId proxyId = actorSystem.Register(proxy); - actorSystem.Send(new NActors::IEventHandle(proxyId, TActorId(), new NHttp::TEvHttpProxy::TEvAddListeningPort(port)), 0, true); + NActors::TActorId proxyId = actorSystem.Register(proxy); + actorSystem.Send(new NActors::IEventHandle(proxyId, TActorId(), new NHttp::TEvHttpProxy::TEvAddListeningPort(port)), 0, true); actorSystem.DispatchEvents(); - NActors::TActorId serverId = actorSystem.AllocateEdgeActor(); + NActors::TActorId serverId = actorSystem.AllocateEdgeActor(); actorSystem.Send(new NActors::IEventHandle(proxyId, serverId, new NHttp::TEvHttpProxy::TEvRegisterHandler("/test", serverId)), 0, true); - NActors::TActorId clientId = actorSystem.AllocateEdgeActor(); + NActors::TActorId clientId = actorSystem.AllocateEdgeActor(); NHttp::THttpOutgoingRequestPtr httpRequest = NHttp::THttpOutgoingRequest::CreateRequestGet("http://[::1]:" + ToString(port) + "/test"); actorSystem.Send(new NActors::IEventHandle(proxyId, clientId, new NHttp::TEvHttpProxy::TEvHttpOutgoingRequest(httpRequest)), 0, true); @@ -213,7 +213,7 @@ Y_UNIT_TEST_SUITE(HttpProxy) { TIpPort port = portManager.GetTcpPort(); TAutoPtr<NActors::IEventHandle> handle; actorSystem.Initialize(); - NMonitoring::TMetricRegistry sensors; + NMonitoring::TMetricRegistry sensors; TString certificateContent = R"___(-----BEGIN PRIVATE KEY----- MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCzRZjodO7Aqe1w @@ -273,7 +273,7 @@ CRA/5XcX13GJwHHj6LCoc3sL7mt8qV9HKY2AOZ88mpObzISZxgPpdKCfjsrdm63V certificateFile.Write(certificateContent.data(), certificateContent.size()); NActors::IActor* proxy = NHttp::CreateHttpProxy(sensors); - NActors::TActorId proxyId = actorSystem.Register(proxy); + NActors::TActorId proxyId = actorSystem.Register(proxy); THolder<NHttp::TEvHttpProxy::TEvAddListeningPort> add = MakeHolder<NHttp::TEvHttpProxy::TEvAddListeningPort>(port); ///////// https configuration @@ -281,13 +281,13 @@ CRA/5XcX13GJwHHj6LCoc3sL7mt8qV9HKY2AOZ88mpObzISZxgPpdKCfjsrdm63V add->CertificateFile = certificateFile.Name(); add->PrivateKeyFile = certificateFile.Name(); ///////// - actorSystem.Send(new NActors::IEventHandle(proxyId, TActorId(), add.Release()), 0, true); + actorSystem.Send(new NActors::IEventHandle(proxyId, TActorId(), add.Release()), 0, true); actorSystem.DispatchEvents(); - NActors::TActorId serverId = actorSystem.AllocateEdgeActor(); + NActors::TActorId serverId = actorSystem.AllocateEdgeActor(); actorSystem.Send(new NActors::IEventHandle(proxyId, serverId, new NHttp::TEvHttpProxy::TEvRegisterHandler("/test", serverId)), 0, true); - NActors::TActorId clientId = actorSystem.AllocateEdgeActor(); + NActors::TActorId clientId = actorSystem.AllocateEdgeActor(); NHttp::THttpOutgoingRequestPtr httpRequest = NHttp::THttpOutgoingRequest::CreateRequestGet("https://[::1]:" + ToString(port) + "/test"); actorSystem.Send(new NActors::IEventHandle(proxyId, clientId, new NHttp::TEvHttpProxy::TEvHttpOutgoingRequest(httpRequest)), 0, true); @@ -314,11 +314,11 @@ CRA/5XcX13GJwHHj6LCoc3sL7mt8qV9HKY2AOZ88mpObzISZxgPpdKCfjsrdm63V NActors::TActorSystem actorSystem(setup); actorSystem.Start(); NHttp::THttpProxy* incomingProxy = new NHttp::THttpProxy(); - NActors::TActorId incomingProxyId = actorSystem.Register(incomingProxy); + NActors::TActorId incomingProxyId = actorSystem.Register(incomingProxy); actorSystem.Send(incomingProxyId, new NHttp::TEvHttpProxy::TEvAddListeningPort(13337)); NHttp::THttpProxy* outgoingProxy = new NHttp::THttpProxy(); - NActors::TActorId outgoingProxyId = actorSystem.Register(outgoingProxy); + NActors::TActorId outgoingProxyId = actorSystem.Register(outgoingProxy); THolder<NHttp::THttpStaticStringRequest> httpRequest = MakeHolder<NHttp::THttpStaticStringRequest>("GET /test HTTP/1.1\r\n\r\n"); actorSystem.Send(outgoingProxyId, new NHttp::TEvHttpProxy::TEvHttpOutgoingRequest("[::]:13337", std::move(httpRequest))); diff --git a/library/cpp/actors/http/ya.make b/library/cpp/actors/http/ya.make index 7ce68b7a75..ade447be3f 100644 --- a/library/cpp/actors/http/ya.make +++ b/library/cpp/actors/http/ya.make @@ -26,7 +26,7 @@ PEERDIR( library/cpp/actors/core library/cpp/actors/interconnect library/cpp/dns - library/cpp/monlib/metrics + library/cpp/monlib/metrics library/cpp/string_utils/quote ) |