Skip to content

Commit c4789a2

Browse files
committed
feat docs: adjust sample in readme to with the github window width
Tests: на прод не влияет commit_hash:23d8a5b32c3e4661da36284123615779ef4b8969
1 parent f592d12 commit c4789a2

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,17 @@ int main(int argc, char* argv[]) {
2525
easy::HttpWith<easy::PgDep>(argc, argv)
2626
// Handles multiple HTTP requests to `/kv` URL concurrently
2727
.Get("/kv", [](formats::json::Value request_json, const easy::PgDep& dep) {
28-
auto key = request_json.As<schemas::KeyRequest>().key; // parser is generated from schema
28+
// JSON parser and serializer are generated from JSON schema by userver
29+
auto key = request_json.As<schemas::KeyRequest>().key;
2930

3031
// Asynchronous execution of the SQL query in transaction. Current thread
3132
// handles other requests while the response from the DB is being received:
3233
auto res = dep.pg().Execute(
33-
storages::postgres::ClusterHostType::kSlave, "SELECT value FROM key_value_table WHERE key=$1", key
34+
storages::postgres::ClusterHostType::kSlave,
35+
// Query is converted into a prepared statement. Subsequent requests
36+
// send only parameters in a binary form and meta information is
37+
// discarded on the DB side, significantly saving network bandwith.
38+
"SELECT value FROM key_value_table WHERE key=$1", key
3439
);
3540

3641
schemas::KeyValue response{key, res[0][0].As<std::string>()};

scripts/docs/en/landing.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,17 @@ int main(int argc, char* argv[]) {
143143
easy::HttpWith&lt;easy::PgDep&gt;(argc, argv)
144144
// Handles multiple HTTP requests to `/kv` URL concurrently
145145
.Get("/kv", [](formats::json::Value request_json, const easy::PgDep&amp; dep) {
146-
auto key = request_json.As<schemas::KeyRequest>().key; // parser is generated from schema
146+
// JSON parser and serializer are generated from JSON schema by userver
147+
auto key = request_json.As&lt;schemas::KeyRequest&gt;().key;
147148

148149
// Asynchronous execution of the SQL query in transaction. Current thread
149150
// handles other requests while the response from the DB is being received:
150151
auto res = dep.pg().Execute(
151-
storages::postgres::ClusterHostType::kSlave, "SELECT value FROM key_value_table WHERE key=$1", key
152+
storages::postgres::ClusterHostType::kSlave,
153+
// Query is converted into a prepared statement. Subsequent requests
154+
// send only parameters in a binary form and meta information is
155+
// discarded on the DB side, significantly saving network bandwith.
156+
"SELECT value FROM key_value_table WHERE key=$1", key
152157
);
153158

154159
schemas::KeyValue response{key, res[0][0].As&lt;std::string&gt;()};

0 commit comments

Comments
 (0)