4#ifndef _Stroika_Framework_WebServer_ConnectionManager_h_
5#define _Stroika_Framework_WebServer_ConnectionManager_h_ 1
7#include "Stroika/Frameworks/StroikaPreComp.h"
12#include "Stroika/Foundation/Common/Property.h"
13#include "Stroika/Foundation/Containers/Collection.h"
14#include "Stroika/Foundation/Containers/KeyedCollection.h"
15#include "Stroika/Foundation/Containers/Set.h"
19#include "Stroika/Foundation/IO/Network/HTTP/Headers.h"
20#include "Stroika/Foundation/IO/Network/Listener.h"
21#include "Stroika/Foundation/IO/Network/SocketAddress.h"
24#include "Stroika/Frameworks/WebServer/CORS.h"
25#include "Stroika/Frameworks/WebServer/Connection.h"
26#include "Stroika/Frameworks/WebServer/Request.h"
27#include "Stroika/Frameworks/WebServer/Response.h"
28#include "Stroika/Frameworks/WebServer/Router.h"
197 static constexpr unsigned int kDefault_MaxConnections{25};
198 static constexpr Socket::BindFlags kDefault_BindFlags{};
200 static inline const CORSOptions kDefault_CORS{[] () {
return kDefault_CORSOptions; }()};
201 static constexpr bool kDefault_AutoComputeETagResponse{
true};
202 static constexpr Duration kDefault_AutomaticTCPDisconnectOnClose{2.0s};
203 static constexpr optional<int> kDefault_Linger{nullopt};
204 static constexpr bool kDefault_TCPNoDelay{
true};
206 static const Options kDefaultOptions;
211 ConnectionManager (
const SocketAddress& bindAddress,
const Sequence<Route>& routes,
const Options&
options = kDefaultOptions);
213 ConnectionManager (
const ConnectionManager&) =
delete;
214#if qStroika_Foundation_Debug_DefaultTracingOn
215 ~ConnectionManager ();
217 ~ConnectionManager () =
default;
221 nonvirtual ConnectionManager& operator= (
const ConnectionManager&) =
delete;
225 decltype ([] (
const Connection::Stats& t) {
return t.fSocketID; })>;
300 size_t fThreadEntryCount{};
307 ThreadPool fThreadPool;
367 ConnectionStatistics fConnections;
384 nonvirtual
Statistics ComputeStatistics_ ()
const;
396 eAfterBeforeInterceptors,
398 using InterceptorAddRelativeTo::eAfterBeforeInterceptors;
399 using InterceptorAddRelativeTo::eAppend;
400 using InterceptorAddRelativeTo::ePrepend;
401 using InterceptorAddRelativeTo::ePrependsToEarly;
411 nonvirtual
void RemoveInterceptor (
const Interceptor& i);
416 nonvirtual
void AbortConnection (
const shared_ptr<Connection>& conn);
419 nonvirtual
void DeriveConnectionDefaultOptionsFromEffectiveOptions_ ();
425 nonvirtual
void WaitForReadyConnectionLoop_ ();
432 nonvirtual
void ReplaceInEarlyInterceptor_ (
const optional<Interceptor>& oldValue,
const optional<Interceptor>& newValue);
437#if qCompilerAndStdLib_RecuriveTypeOrFunctionDependencyTooComplex_Buggy
439 shared_ptr<Connection::Options> fUseDefaultConnectionOptions_BWA_{make_shared<Connection::Options> ()};
440 Connection::Options& fUseDefaultConnectionOptions_{*fUseDefaultConnectionOptions_BWA_};
442 Connection::Options fUseDefaultConnectionOptions_;
454 struct MyWaitForIOReady_Traits_ {
455 using HighLevelType = shared_ptr<Connection>;
456 static inline auto GetSDKPollable (
const HighLevelType& t)
458 return t->socket ().GetNativeSocket ();
485 IO::Network::Listener fListener_;
488 inline const ConnectionManager::Options ConnectionManager::kDefaultOptions;
497#include "ConnectionManager.inl"
String is like std::u32string, except it is much easier to use, often much more space efficient,...
A Collection<T> is a container to manage an un-ordered collection of items, without equality defined ...
a cross between Mapping<KEY, T> and Collection<T> and Set<T>
Set<T> is a container of T, where once an item is added, additionally adds () do nothing.
Wrap any object with Synchronized<> and it can be used similarly to the base type,...
Simple wrapper on WaitForIOReady (POSIX select/poll/etc API) - except it allows for the list if polle...
Duration is a chrono::duration<double> (=.
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
Common::ReadOnlyProperty< Statistics > statistics
Common::ReadOnlyProperty< ConnectionStatsCollection > connections
Common::ReadOnlyProperty< Traversal::Iterable< SocketAddress > > bindings
Return the socket addresses the webserver (connection manager) is listening on (to serve web content)...
Common::Property< Sequence< Interceptor > > earlyInterceptors
Common::Property< Sequence< Interceptor > > beforeInterceptors
Common::Property< optional< Interceptor > > defaultErrorHandler
Common::ReadOnlyProperty< const Options & > options
Common::Property< Sequence< Interceptor > > afterInterceptors
ConnectionManager::Options specify things like default headers, caching policies, binding flags (not ...
optional< unsigned int > fMaxConnections
optional< String > fThreadPoolName
optional< CORSOptions > fCORS
optional< Headers > fDefaultResponseHeaders
optional< bool > fAutoComputeETagResponse
sets the initial value for each Response. Harmless except for the slight performance cost (wont alway...
optional< Headers > fDefaultGETResponseHeaders
optional< Containers::Set< HTTP::ContentEncoding > > fSupportedCompressionEncodings
override the set of compression encodings the WebServer supports (default is all the Stroika implemen...
optional< unsigned int > fMaxConcurrentlyHandledConnections
optional< Duration > fAutomaticTCPDisconnectOnClose
Duration fConnectionPiningForTheFjordsDelay
optional< unsigned int > fTCPBacklog
optional< size_t > fAutomaticTransferChunkSize
controls whether to use Transfer-Coding: chunked or not
optional< Socket::BindFlags > fBindFlags
optional< bool > fTCPNoDelay
CommonStatistics< Duration > fDurationOfOpenConnections
CommonStatistics< Duration > fDurationOfOpenConnectionsRequests
size_t fNumberOfActiveConnections
CommonStatistics< Duration > fDurationOfActiveConnectionsRequests
size_t fNumberOfOpenConnections
nonvirtual Characters::String ToString() const
size_t fConnectionsPiningForTheFjords
nonvirtual Characters::String ToString() const