-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easy-peasy library (WIP) #767
Conversation
@@ -0,0 +1,3 @@ | |||
## Easy - library for single file prototyping | |||
|
|||
TODO: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
шото надо дописать
libraries/easy/src/easy.cpp
Outdated
app.AddComponentsConfig(R"~( | ||
postgres: | ||
dbconnection#env: POSTGRESQL | ||
dbconnection#fallback: 'postgresql://testsuite@localhost:15433/postgres' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а может без фолбека? всегда будем подсовывать env
def pgsql_local(service_tmpdir, service_binary, pgsql_local_create): | ||
schema_path = service_tmpdir.joinpath("schemas") | ||
os.mkdir(schema_path) | ||
subprocess.run([service_binary, "--dump-schema", schema_path]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это явно не в этой фикстуре должно находиться
def pgsql_local(service_tmpdir, service_binary, pgsql_local_create): | ||
schema_path = service_tmpdir.joinpath("schemas") | ||
os.mkdir(schema_path) | ||
subprocess.run([service_binary, "--dump-schema", schema_path]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не тут
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хм, действительно станет покрасивее, если в отдельную фикстуру вынести
ARGS | ||
# Map '/components/schemas/*' JSONSchema types to C++ types in 'schemas' namespace | ||
-n "/components/schemas/([^/]*)/=schemas::{0}" | ||
-f "(.*)={0}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вот это нужно изничтожить, оно не будет жить
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-f является сейчас обязательным параметром
easy::HttpWith(argc, argv) | ||
.DefaultContentType(http::content_type::kTextPlain) | ||
.Get("/hi/{user}", &Greet) | ||
.Get("/hi", Hi{}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нужны какие-то комменты
типа можно передать структуру
можно лямбду/функцию
можно еще что-то
когда что эффективно?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Одинаково по эффективности... Добавлю это в доку
|
||
int main(int argc, char* argv[]) { | ||
easy::HttpWith(argc, argv) | ||
.DefaultContentType(http::content_type::kTextPlain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
на прием или на отдачу?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DefaultResponseContentType? Как-то длиновато
HttpWith<Dependency>::Callback::Callback(Function func) { | ||
using server::http::HttpRequest; | ||
|
||
if constexpr (std::is_invocable_r_v<formats::json::Value, Function, formats::json::Value, const Dependency&>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а это не получится на разные перегрузки с enable_if разделить?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно попробовать, но получится хуже. Сейчас можно выдать читаемую диагностику по доступным сигнатурам в static_assert, с перегрузками так не получится. Ну и с перегрузками сложнее понять что происходит - порядок выбора перегрузок становится не очевидным.
Так что через подобную лесенку получается понятнее и поддерживаемее
@@ -0,0 +1,11 @@ | |||
project(userver-easy CXX) | |||
|
|||
userver_module(easy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module -> component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, но не в этом PR
|
||
if(USERVER_BUILD_SAMPLES) | ||
add_subdirectory(samples) | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_sample_subdirectory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Возможно, но не в этом PR
No description provided.