Update 1.3.0.md

This commit is contained in:
Leonid Stryzhevskyi 2021-10-13 03:03:42 +03:00 committed by GitHub
parent cc40fe69c8
commit 00ee3eea78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ Contents:
- [The New oatpp::String](#the-new-oatppstring)
- [ConnectionPool::get() Timeout](#connectionpoolget-timeout)
- [JSON Serializer Escape Flags](#json-serializer-escape-flags)
- [ConnectionMonitor](#connectionmonitor)
- [Response::getBody()](#responsegetbody)
- [data::stream::FIFOStream](#datastreamfifostream)
- [data::stream::BufferedInputStream](#datastreambufferedinputstream)
@ -127,6 +128,38 @@ Output:
res='"https://oatpp.io/"' # solidus isn't escaped
```
## ConnectionMonitor
`oatpp::network::monitor::ConnectionMonitor` is a middleman who's able to monitor provided connections and close those ones that not satisfy selected rules.
```cpp
OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)([] {
auto connectionProvider = oatpp::network::tcp::server::ConnectionProvider::createShared({"0.0.0.0", 8000, oatpp::network::Address::IP_4});
auto monitor = std::make_shared<oatpp::network::monitor::ConnectionMonitor>(connectionProvider);
/* close all connections that stay opened for more than 120 seconds */
monitor->addMetricsChecker(
std::make_shared<oatpp::network::monitor::ConnectionMaxAgeChecker>(
std::chrono::seconds(120)
)
);
/* close all connections that have had no successful reads and writes for longer than 5 seconds */
monitor->addMetricsChecker(
std::make_shared<oatpp::network::monitor::ConnectionInactivityChecker>(
std::chrono::seconds(5),
std::chrono::seconds(5),
)
);
return monitor;
}());
```
**Note:** `ConnectionMonitor` also works with `ClientConnectionProvider` as well.
## Response::getBody()
`oatpp::web::protocol::http::outgoing::Response` has a new method `getBody()` to retreive the body of the response. This is handy for response interceptors.