Skip to content
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

Closed
wants to merge 22 commits into from
Closed

Conversation

apolukhin
Copy link
Member

No description provided.

@@ -0,0 +1,3 @@
## Easy - library for single file prototyping

TODO:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

шото надо дописать

app.AddComponentsConfig(R"~(
postgres:
dbconnection#env: POSTGRESQL
dbconnection#fallback: 'postgresql://testsuite@localhost:15433/postgres'
Copy link
Collaborator

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])
Copy link
Collaborator

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])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не тут

Copy link
Member Author

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}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вот это нужно изничтожить, оно не будет жить

Copy link
Member Author

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{});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нужны какие-то комменты
типа можно передать структуру
можно лямбду/функцию
можно еще что-то
когда что эффективно?

Copy link
Member Author

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

на прием или на отдачу?

Copy link
Member Author

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&>) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а это не получится на разные перегрузки с enable_if разделить?

Copy link
Member Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module -> component?

Copy link
Member Author

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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add_sample_subdirectory?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Возможно, но не в этом PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants