userver
2.6
| قوالب الخدمة | تطوير / جذع أخضر | v2.0 | v1.0 |
|---|---|---|---|
| جوهر: | [➚] | [➚] | |
| postgreSQL: | [➚] | [➚] | |
| GRPC+PostgreSQL: | [➚] | [➚] |
Userver هو إطار غير متزامن مفتوح المصدر مع مجموعة غنية من التجريدات لإنشاء Microservices و C ++ Microservices C ++.
يحل الإطار مشكلة تفاعلات الإدخال/الإخراج الفعالة بشفافية للمطورين. العمليات التي من شأنها أن تعلق عادة مؤشر ترابط التنفيذ لا تعلق عليه. بدلاً من ذلك ، يقوم مؤشر الترابط بمعالجة الطلبات والمهام الأخرى ويعود إلى معالجة العملية فقط عندما يكون من الممكن التنفيذ على الفور:
# include < userver/easy.hpp >
# include " schemas/key_value.hpp "
int main ( int argc, char * argv[]) {
using namespace userver ;
easy::HttpWith<easy::PgDep>(argc, argv)
// Handles multiple HTTP requests to `/kv` URL concurrently
. Get ( " /kv " , [](formats::json::Value request_json, const easy::PgDep& dep) {
// JSON parser and serializer are generated from JSON schema by userver
auto key = request_json. As <schemas::KeyRequest>(). key ;
// Asynchronous execution of the SQL query in transaction. Current thread
// handles other requests while the response from the DB is being received:
auto res = dep. pg (). Execute (
storages::postgres::ClusterHostType:: kSlave ,
// Query is converted into a prepared statement. Subsequent requests
// send only parameters in a binary form and meta information is
// discarded on the DB side, significantly saving network bandwidth.
" SELECT value FROM key_value_table WHERE key=$1 " , key
);
schemas::KeyValue response{key, res[ 0 ][ 0 ]. As <std::string>()};
return formats::json::ValueBuilder{response}. ExtractValue ();
});
}نتيجة لذلك ، مع إطار العمل ، تحصل على رمز المصدر المباشر ، تجنب مفاتيح سياق CPU المستهلكة من نظام التشغيل ، واستخدام وحدة المعالجة المركزية بكفاءة مع كمية صغيرة من مؤشرات ترابط التنفيذ.
يمكنك معرفة المزيد عن التاريخ والميزات الرئيسية للمستخدم من منشوراتنا ومقاطع الفيديو الخاصة بنا.
انظر المستندات لمزيد من المعلومات.