54 using OnDisconnectHook = std::function<void(
Connection const&)>;
57 using hash_type = std::hash<std::string_view>;
58 using is_transparent = void;
61 operator()(
char const* str)
const;
63 operator()(std::string_view str)
const;
65 operator()(std::string
const& str)
const;
68 using TargetToHandlerMap = std::unordered_map<std::string, MessageHandler, StringHash, std::equal_to<>>;
74 ProcessingPolicy processingPolicy_;
75 std::optional<size_t> maxParallelRequests_;
77 std::reference_wrapper<util::TagDecoratorFactory> tagFactory_;
78 std::optional<size_t> maxSubscriptionSendQueueSize_;
80 OnDisconnectHook onDisconnectHook_;
82 TargetToHandlerMap getHandlers_;
83 TargetToHandlerMap postHandlers_;
84 std::optional<MessageHandler> wsHandler_;
86 boost::signals2::signal<void()> onStop_;
87 std::unique_ptr<std::atomic_bool> stopping_ = std::make_unique<std::atomic_bool>(
false);
89 std::reference_wrapper<util::prometheus::GaugeInt> connectionsCounter_ =
96 ProcessingPolicy processingPolicy,
97 std::optional<size_t> maxParallelRequests,
99 std::optional<size_t> maxSubscriptionSendQueueSize,
100 OnDisconnectHook onDisconnectHook
103 static constexpr std::chrono::milliseconds kCLOSE_CONNECTION_TIMEOUT{500};
106 onGet(std::string
const& target, MessageHandler handler);
109 onPost(std::string
const& target, MessageHandler handler);
112 onWs(MessageHandler handler);
115 processConnection(ConnectionPtr connection, boost::asio::yield_context yield);
118 stopConnection(Connection& connection, boost::asio::yield_context yield);
121 stop(boost::asio::yield_context yield);
135 handleError(Error
const& error, Connection
const& connection)
const;
145 sequentRequestResponseLoop(
146 Connection& connection,
148 boost::asio::yield_context yield
152 parallelRequestResponseLoop(
153 Connection& connection,
155 boost::asio::yield_context yield
160 Connection& connection,
162 Request
const& request,
163 boost::asio::yield_context yield
168 ConnectionMetadata& connectionMetadata,
170 Request
const& request,
171 boost::asio::yield_context yield
static util::prometheus::GaugeInt & gaugeInt(std::string name, util::prometheus::Labels labels, std::optional< std::string > description=std::nullopt)
Get an integer based gauge metric. It will be created if it doesn't exist.
Definition Prometheus.cpp:210
std::shared_ptr< SubscriptionContextInterface > SubscriptionContextPtr
An alias for shared pointer to a SubscriptionContextInterface.
Definition SubscriptionContextInterface.hpp:86