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 ConnectionHandler(ConnectionHandler&&) =
delete;
105 static constexpr std::chrono::milliseconds kCLOSE_CONNECTION_TIMEOUT{500};
108 onGet(std::string
const& target, MessageHandler handler);
111 onPost(std::string
const& target, MessageHandler handler);
114 onWs(MessageHandler handler);
117 processConnection(ConnectionPtr connection, boost::asio::yield_context yield);
120 stopConnection(Connection& connection, boost::asio::yield_context yield);
123 stop(boost::asio::yield_context yield);
137 handleError(Error
const& error, Connection
const& connection)
const;
147 sequentRequestResponseLoop(
148 Connection& connection,
150 boost::asio::yield_context yield
154 parallelRequestResponseLoop(
155 Connection& connection,
157 boost::asio::yield_context yield
162 Connection& connection,
164 Request
const& request,
165 boost::asio::yield_context yield
170 ConnectionMetadata& connectionMetadata,
172 Request
const& request,
173 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