55 using OnDisconnectHook = std::function<void(
Connection const&)>;
56 using OnIpChangeHook = std::function<void(std::string
const&, std::string
const&)>;
57 using TargetToHandlerMap = std::unordered_map<std::string, MessageHandler, util::StringHash, std::equal_to<>>;
63 ProcessingPolicy processingPolicy_;
64 std::optional<size_t> maxParallelRequests_;
66 std::reference_wrapper<util::TagDecoratorFactory> tagFactory_;
67 std::optional<size_t> maxSubscriptionSendQueueSize_;
71 OnDisconnectHook onDisconnectHook_;
72 OnIpChangeHook onIpChangeHook_;
74 TargetToHandlerMap getHandlers_;
75 TargetToHandlerMap postHandlers_;
76 std::optional<MessageHandler> wsHandler_;
78 boost::signals2::signal<void()> onStop_;
79 std::unique_ptr<std::atomic_bool> stopping_ = std::make_unique<std::atomic_bool>(
false);
81 std::reference_wrapper<util::prometheus::GaugeInt> connectionsCounter_ =
88 ProcessingPolicy processingPolicy,
89 std::optional<size_t> maxParallelRequests,
91 std::optional<size_t> maxSubscriptionSendQueueSize,
93 OnDisconnectHook onDisconnectHook,
94 OnIpChangeHook onIpChangeHook
99 static constexpr std::chrono::milliseconds kCLOSE_CONNECTION_TIMEOUT{500};
102 onGet(std::string
const& target, MessageHandler handler);
105 onPost(std::string
const& target, MessageHandler handler);
108 onWs(MessageHandler handler);
111 processConnection(ConnectionPtr connection, boost::asio::yield_context yield);
114 stopConnection(
Connection& connection, boost::asio::yield_context yield);
117 stop(boost::asio::yield_context yield);
131 handleError(Error
const& error,
Connection const& connection)
const;
141 sequentRequestResponseLoop(
144 boost::asio::yield_context yield
148 parallelRequestResponseLoop(
151 boost::asio::yield_context yield
159 boost::asio::yield_context yield
167 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:216
std::shared_ptr< SubscriptionContextInterface > SubscriptionContextPtr
An alias for shared pointer to a SubscriptionContextInterface.
Definition SubscriptionContextInterface.hpp:83