zrb 0.23.0__py3-none-any.whl → 0.24.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zrb/__init__.py +2 -0
- zrb/builtin/devtool/install/_input.py +2 -2
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/start.py +5 -6
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_helper.py +1 -52
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/start.py +5 -6
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/start.py +4 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/README.md +84 -8
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/loadtest/locustfile.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/loadtest/template.env +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/config.py +59 -61
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/frontend/src/routes/+layout.svelte +1 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/frontend/vite.config.ts +7 -1
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/app/__init__.py +0 -0
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/{app.py → app/app.py} +30 -29
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/{app_lifespan.py → app/app_lifespan.py} +16 -16
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/{app_state.py → app/app_state.py} +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/db_connection.py +14 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/frontend_index.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/log.py +6 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/messagebus.py +33 -33
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/rpc.py +9 -9
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/main.py +1 -3
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/access_token_scheme.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/access_token_util.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/model/user_model.py +6 -6
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/refresh_token_util.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/integration/user.py +18 -18
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/auth/register_module.py +9 -9
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/module/log/register_module.py +9 -9
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/template.env +5 -2
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_group_crud.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_permission_crud.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_crud.py +7 -7
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/auth/test_user_login.py +14 -14
- zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/test/test_liveness_and_readiness.py +3 -3
- zrb/builtin/project/add/fastapp/crud/_helper/__init__.py +7 -0
- zrb/builtin/project/add/fastapp/crud/_helper/_common.py +8 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_api.py +45 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_permission.py +40 -0
- zrb/builtin/project/add/fastapp/crud/_helper/register_rpc.py +45 -0
- zrb/builtin/project/add/fastapp/crud/crud.py +3 -12
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/entity/snake_zrb_entity_name/repo.py +12 -1
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/schema/snake_zrb_entity_name.py +1 -0
- zrb/builtin/project/add/fastapp/crud/template/src/kebab-zrb-app-name/test/snake_zrb_module_name/test_snake_zrb_entity_name.py +8 -7
- zrb/builtin/project/add/fastapp/field/_helper/__init__.py +17 -0
- zrb/builtin/project/add/fastapp/field/_helper/_common.py +102 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_delete_page.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_detail_page.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_insert_page.py +62 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_list_page.py +47 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_repo.py +47 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_schema.py +45 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_test.py +49 -0
- zrb/builtin/project/add/fastapp/field/_helper/inject_update_page.py +50 -0
- zrb/builtin/project/add/fastapp/field/_input.py +14 -2
- zrb/builtin/project/add/fastapp/field/field.py +70 -90
- zrb/builtin/project/add/fastapp/module/_helper/__init__.py +17 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_all_disabled_env.py +22 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_all_enabled_env.py +22 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_deployment_template_env.py +25 -0
- zrb/builtin/project/add/fastapp/module/_helper/append_src_template_env.py +25 -0
- zrb/builtin/project/add/fastapp/module/_helper/create_app_config.py +29 -0
- zrb/builtin/project/add/fastapp/module/_helper/create_microservice_config.py +158 -0
- zrb/builtin/project/add/fastapp/module/_helper/register_migration.py +35 -0
- zrb/builtin/project/add/fastapp/module/_helper/register_module.py +33 -0
- zrb/builtin/project/add/fastapp/module/module.py +8 -37
- zrb/builtin/project/add/fastapp/module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/migrate.py +2 -2
- zrb/builtin/project/add/fastapp/module/template/src/kebab-zrb-app-name/src/module/snake_zrb_module_name/register_module.py +9 -9
- zrb/builtin/project/add/plugin/plugin.py +2 -2
- zrb/builtin/project/create/create.py +2 -2
- zrb/builtin/version.py +3 -3
- zrb/config/config.py +14 -14
- zrb/helper/callable.py +3 -1
- zrb/helper/cli.py +4 -4
- zrb/helper/file/copy_tree.py +26 -10
- zrb/helper/log.py +3 -3
- zrb/helper/string/parse_replacement.py +1 -1
- zrb/helper/typecheck.py +2 -2
- zrb/helper/typing.py +2 -2
- zrb/helper/util.py +12 -0
- zrb/runner.py +2 -2
- zrb/task/base_remote_cmd_task.py +5 -1
- zrb/task/base_task/base_task.py +3 -3
- zrb/task/base_task/component/base_task_model.py +9 -9
- zrb/task/cmd_task.py +15 -7
- zrb/task/docker_compose_start_task.py +151 -0
- zrb/task/docker_compose_task.py +35 -16
- zrb/task_input/base_input.py +2 -2
- zrb/task_input/multiline_input.py +2 -2
- {zrb-0.23.0.dist-info → zrb-0.24.0.dist-info}/METADATA +3 -3
- {zrb-0.23.0.dist-info → zrb-0.24.0.dist-info}/RECORD +98 -80
- zrb/builtin/project/add/app/generator/template/src/kebab-zrb-package-name/src/snake_zrb_package_name/snake_zrb_generator_name/template/_automate/snake_zrb_app_name/container/init.py +0 -34
- zrb/builtin/project/add/app/python/template/_automate/snake_zrb_app_name/container/init.py +0 -34
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/microservices/init.py +0 -36
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/monolith/init.py +0 -36
- zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/init.py +0 -26
- zrb/builtin/project/add/fastapp/crud/_helper.py +0 -118
- zrb/builtin/project/add/fastapp/field/_helper.py +0 -342
- zrb/builtin/project/add/fastapp/module/_helper.py +0 -313
- {zrb-0.23.0.dist-info → zrb-0.24.0.dist-info}/LICENSE +0 -0
- {zrb-0.23.0.dist-info → zrb-0.24.0.dist-info}/WHEEL +0 -0
- {zrb-0.23.0.dist-info → zrb-0.24.0.dist-info}/entry_points.txt +0 -0
zrb/__init__.py
CHANGED
@@ -14,6 +14,7 @@ from zrb.task.base_remote_cmd_task import BaseRemoteCmdTask, RemoteConfig
|
|
14
14
|
from zrb.task.checker import Checker
|
15
15
|
from zrb.task.cmd_task import CmdTask
|
16
16
|
from zrb.task.decorator import python_task
|
17
|
+
from zrb.task.docker_compose_start_task import DockerComposeStartTask
|
17
18
|
from zrb.task.docker_compose_task import DockerComposeTask, ServiceConfig
|
18
19
|
from zrb.task.flow_task import FlowTask
|
19
20
|
from zrb.task.http_checker import HTTPChecker
|
@@ -66,6 +67,7 @@ assert python_task
|
|
66
67
|
assert Task
|
67
68
|
assert CmdTask
|
68
69
|
assert DockerComposeTask
|
70
|
+
assert DockerComposeStartTask
|
69
71
|
assert ServiceConfig
|
70
72
|
assert BaseRemoteCmdTask
|
71
73
|
assert RemoteConfig
|
@@ -1,9 +1,9 @@
|
|
1
|
-
from zrb.config.config import
|
1
|
+
from zrb.config.config import DEFAULT_SHELL
|
2
2
|
from zrb.task_input.str_input import StrInput
|
3
3
|
|
4
4
|
terminal_config_file_input = StrInput(
|
5
5
|
name="config-file",
|
6
6
|
shortcut="c",
|
7
7
|
prompt="Config file",
|
8
|
-
default="~/.zshrc" if
|
8
|
+
default="~/.zshrc" if DEFAULT_SHELL == "zsh" else "~/.bashrc",
|
9
9
|
)
|
@@ -1,16 +1,17 @@
|
|
1
|
-
from zrb import
|
1
|
+
from zrb import DockerComposeStartTask, HTTPChecker, runner
|
2
2
|
|
3
3
|
from ..._project import start_project_containers
|
4
4
|
from .._constant import RESOURCE_DIR
|
5
5
|
from .._input import host_input, https_input, local_input
|
6
|
+
from ..image import build_snake_zrb_app_name_image
|
6
7
|
from ..image._env import image_env
|
7
8
|
from ..image._input import image_input
|
8
9
|
from ._env import compose_env_file, host_port_env
|
9
10
|
from ._group import snake_zrb_app_name_container_group
|
10
11
|
from ._service_config import snake_zrb_app_name_service_config
|
11
|
-
from .
|
12
|
+
from .remove import remove_snake_zrb_app_name_container
|
12
13
|
|
13
|
-
start_snake_zrb_app_name_container =
|
14
|
+
start_snake_zrb_app_name_container = DockerComposeStartTask(
|
14
15
|
icon="🐳",
|
15
16
|
name="start",
|
16
17
|
description="Start human readable zrb app name container",
|
@@ -22,10 +23,8 @@ start_snake_zrb_app_name_container = DockerComposeTask(
|
|
22
23
|
image_input,
|
23
24
|
],
|
24
25
|
should_execute="{{ input.local_snake_zrb_app_name}}",
|
25
|
-
upstreams=[
|
26
|
+
upstreams=[build_snake_zrb_app_name_image, remove_snake_zrb_app_name_container],
|
26
27
|
cwd=RESOURCE_DIR,
|
27
|
-
compose_cmd="logs",
|
28
|
-
compose_flags=["-f"],
|
29
28
|
compose_env_prefix="CONTAINER_ZRB_ENV_PREFIX",
|
30
29
|
compose_service_configs={"snake_zrb_app_name": snake_zrb_app_name_service_config},
|
31
30
|
env_files=[compose_env_file],
|
@@ -1,16 +1,17 @@
|
|
1
|
-
from zrb import
|
1
|
+
from zrb import DockerComposeStartTask, HTTPChecker, runner
|
2
2
|
|
3
3
|
from ..._project import start_project_containers
|
4
4
|
from .._constant import RESOURCE_DIR
|
5
5
|
from .._input import host_input, https_input, local_input
|
6
|
+
from ..image import build_snake_zrb_app_name_image
|
6
7
|
from ..image._env import image_env
|
7
8
|
from ..image._input import image_input
|
8
9
|
from ._env import compose_env_file, host_port_env
|
9
10
|
from ._group import snake_zrb_app_name_container_group
|
10
11
|
from ._service_config import snake_zrb_app_name_service_config
|
11
|
-
from .
|
12
|
+
from .remove import remove_snake_zrb_app_name_container
|
12
13
|
|
13
|
-
start_snake_zrb_app_name_container =
|
14
|
+
start_snake_zrb_app_name_container = DockerComposeStartTask(
|
14
15
|
icon="🐳",
|
15
16
|
name="start",
|
16
17
|
description="Start human readable zrb app name container",
|
@@ -22,10 +23,8 @@ start_snake_zrb_app_name_container = DockerComposeTask(
|
|
22
23
|
image_input,
|
23
24
|
],
|
24
25
|
should_execute="{{ input.local_snake_zrb_app_name}}",
|
25
|
-
upstreams=[
|
26
|
+
upstreams=[build_snake_zrb_app_name_image, remove_snake_zrb_app_name_container],
|
26
27
|
cwd=RESOURCE_DIR,
|
27
|
-
compose_cmd="logs",
|
28
|
-
compose_flags=["-f"],
|
29
28
|
compose_env_prefix="CONTAINER_ZRB_ENV_PREFIX",
|
30
29
|
compose_service_configs={"snake_zrb_app_name": snake_zrb_app_name_service_config},
|
31
30
|
env_files=[compose_env_file],
|
zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/_helper.py
CHANGED
@@ -1,51 +1,4 @@
|
|
1
|
-
from typing import Any
|
2
|
-
|
3
|
-
from zrb import Task
|
4
|
-
|
5
|
-
|
6
|
-
def get_support_container_compose_profiles(*args: Any, **kwargs: Any) -> List[str]:
|
7
|
-
task: Task = kwargs.get("_task")
|
8
|
-
env_map = task.get_env_map()
|
9
|
-
compose_profiles: List[str] = []
|
10
|
-
broker_type = env_map.get("APP_BROKER_TYPE", "rabbitmq")
|
11
|
-
if broker_type in ["rabbitmq", "kafka"]:
|
12
|
-
compose_profiles.append(broker_type)
|
13
|
-
if kwargs.get("enable_snake_zrb_app_name_monitoring", False):
|
14
|
-
compose_profiles.append("monitoring")
|
15
|
-
return compose_profiles
|
16
|
-
|
17
|
-
|
18
|
-
def get_container_compose_profiles(*args: Any, **kwargs: Any) -> str:
|
19
|
-
compose_profiles = get_support_container_compose_profiles(*args, **kwargs)
|
20
|
-
compose_profiles.append(
|
21
|
-
kwargs.get("snake_zrb_app_name_run_mode", "monolith"),
|
22
|
-
)
|
23
|
-
return compose_profiles
|
24
|
-
|
25
|
-
|
26
|
-
def activate_support_compose_profile(*args: Any, **kwargs: Any) -> str:
|
27
|
-
compose_profiles = get_support_container_compose_profiles(*args, **kwargs)
|
28
|
-
compose_profile_str = ",".join(compose_profiles)
|
29
|
-
return f"export COMPOSE_PROFILES={compose_profile_str}"
|
30
|
-
|
31
|
-
|
32
|
-
def should_start_support_container(*args: Any, **kwargs: Any) -> bool:
|
33
|
-
if not kwargs.get("local_snake_zrb_app_name", True):
|
34
|
-
return False
|
35
|
-
compose_profiles = get_support_container_compose_profiles(*args, **kwargs)
|
36
|
-
return len(compose_profiles) > 0
|
37
|
-
|
38
|
-
|
39
|
-
def should_start_local_monolith(*args: Any, **kwargs: Any) -> bool:
|
40
|
-
if not kwargs.get("local_snake_zrb_app_name", True):
|
41
|
-
return False
|
42
|
-
return kwargs.get("snake_zrb_app_name_run_mode", "monolith") == "monolith"
|
43
|
-
|
44
|
-
|
45
|
-
def activate_selected_compose_profile(*args: Any, **kwargs: Any) -> str:
|
46
|
-
compose_profiles = get_container_compose_profiles(*args, **kwargs)
|
47
|
-
compose_profile_str = ",".join(compose_profiles)
|
48
|
-
return f"export COMPOSE_PROFILES={compose_profile_str}"
|
1
|
+
from typing import Any
|
49
2
|
|
50
3
|
|
51
4
|
def activate_all_compose_profile(*args: Any, **kwargs: Any) -> str:
|
@@ -53,7 +6,3 @@ def activate_all_compose_profile(*args: Any, **kwargs: Any) -> str:
|
|
53
6
|
["monitoring", "monolith", "microservices", "kafka", "rabbitmq"]
|
54
7
|
)
|
55
8
|
return f"export COMPOSE_PROFILES={compose_profile_str}"
|
56
|
-
|
57
|
-
|
58
|
-
def should_start_container(*args: Any, **kwargs: Any) -> bool:
|
59
|
-
return kwargs.get("local_snake_zrb_app_name", True)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from zrb import
|
1
|
+
from zrb import DockerComposeStartTask, runner
|
2
2
|
|
3
3
|
from ...._project import start_project_containers
|
4
4
|
from ..._checker import (
|
@@ -13,16 +13,17 @@ from ..._checker import (
|
|
13
13
|
)
|
14
14
|
from ..._constant import PREFER_MICROSERVICES, RESOURCE_DIR
|
15
15
|
from ..._input import host_input, https_input, local_input
|
16
|
+
from ...image import build_snake_zrb_app_name_image
|
16
17
|
from ...image._env import image_env
|
17
18
|
from ...image._input import image_input
|
18
19
|
from .._env import compose_env_file, host_port_env
|
19
20
|
from .._input import enable_monitoring_input
|
20
21
|
from .._service_config import snake_zrb_app_name_service_configs
|
22
|
+
from ..remove import remove_snake_zrb_app_name_container
|
21
23
|
from ._group import snake_zrb_app_name_microservices_container_group
|
22
24
|
from ._helper import activate_microservices_compose_profile
|
23
|
-
from .init import init_snake_zrb_app_name_microservices_container
|
24
25
|
|
25
|
-
start_snake_zrb_app_name_microservices_container =
|
26
|
+
start_snake_zrb_app_name_microservices_container = DockerComposeStartTask(
|
26
27
|
icon="🐳",
|
27
28
|
name="start",
|
28
29
|
description="Start human readable zrb app name container",
|
@@ -35,11 +36,9 @@ start_snake_zrb_app_name_microservices_container = DockerComposeTask(
|
|
35
36
|
image_input,
|
36
37
|
],
|
37
38
|
should_execute="{{ input.local_snake_zrb_app_name}}",
|
38
|
-
upstreams=[
|
39
|
+
upstreams=[build_snake_zrb_app_name_image, remove_snake_zrb_app_name_container],
|
39
40
|
cwd=RESOURCE_DIR,
|
40
41
|
setup_cmd=activate_microservices_compose_profile,
|
41
|
-
compose_cmd="logs",
|
42
|
-
compose_flags=["-f"],
|
43
42
|
compose_env_prefix="CONTAINER_ZRB_ENV_PREFIX",
|
44
43
|
compose_service_configs=snake_zrb_app_name_service_configs,
|
45
44
|
env_files=[compose_env_file],
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from zrb import
|
1
|
+
from zrb import DockerComposeStartTask, runner
|
2
2
|
|
3
3
|
from ...._project import start_project_containers
|
4
4
|
from ..._checker import (
|
@@ -13,16 +13,17 @@ from ..._checker import (
|
|
13
13
|
)
|
14
14
|
from ..._constant import PREFER_MICROSERVICES, RESOURCE_DIR
|
15
15
|
from ..._input import host_input, https_input, local_input
|
16
|
+
from ...image import build_snake_zrb_app_name_image
|
16
17
|
from ...image._env import image_env
|
17
18
|
from ...image._input import image_input
|
18
19
|
from .._env import compose_env_file, host_port_env
|
19
20
|
from .._input import enable_monitoring_input
|
20
21
|
from .._service_config import snake_zrb_app_name_service_configs
|
22
|
+
from ..remove import remove_snake_zrb_app_name_container
|
21
23
|
from ._group import snake_zrb_app_name_monolith_container_group
|
22
24
|
from ._helper import activate_monolith_compose_profile
|
23
|
-
from .init import init_snake_zrb_app_name_monolith_container
|
24
25
|
|
25
|
-
start_snake_zrb_app_name_monolith_container =
|
26
|
+
start_snake_zrb_app_name_monolith_container = DockerComposeStartTask(
|
26
27
|
icon="🐳",
|
27
28
|
name="start",
|
28
29
|
description="Start human readable zrb app name container",
|
@@ -35,11 +36,9 @@ start_snake_zrb_app_name_monolith_container = DockerComposeTask(
|
|
35
36
|
image_input,
|
36
37
|
],
|
37
38
|
should_execute="{{ input.local_snake_zrb_app_name}}",
|
38
|
-
upstreams=[
|
39
|
+
upstreams=[build_snake_zrb_app_name_image, remove_snake_zrb_app_name_container],
|
39
40
|
cwd=RESOURCE_DIR,
|
40
41
|
setup_cmd=activate_monolith_compose_profile,
|
41
|
-
compose_cmd="logs",
|
42
|
-
compose_flags=["-f"],
|
43
42
|
compose_env_prefix="CONTAINER_ZRB_ENV_PREFIX",
|
44
43
|
compose_service_configs=snake_zrb_app_name_service_configs,
|
45
44
|
env_files=[compose_env_file],
|
zrb/builtin/project/add/fastapp/app/template/_automate/snake_zrb_app_name/container/support/start.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from zrb import
|
1
|
+
from zrb import DockerComposeStartTask, runner
|
2
2
|
|
3
3
|
from ..._checker import (
|
4
4
|
kafka_outside_checker,
|
@@ -15,11 +15,11 @@ from ...image._input import image_input
|
|
15
15
|
from .._env import compose_env_file
|
16
16
|
from .._input import enable_monitoring_input
|
17
17
|
from .._service_config import snake_zrb_app_name_service_configs
|
18
|
+
from ..remove import remove_snake_zrb_app_name_container
|
18
19
|
from ._group import snake_zrb_app_name_support_container_group
|
19
20
|
from ._helper import activate_support_compose_profile, should_start_support_container
|
20
|
-
from .init import init_snake_zrb_app_name_support_container
|
21
21
|
|
22
|
-
start_snake_zrb_app_name_support_container =
|
22
|
+
start_snake_zrb_app_name_support_container = DockerComposeStartTask(
|
23
23
|
icon="🐳",
|
24
24
|
name="start",
|
25
25
|
description="Start human readable zrb app name container",
|
@@ -32,11 +32,9 @@ start_snake_zrb_app_name_support_container = DockerComposeTask(
|
|
32
32
|
image_input,
|
33
33
|
],
|
34
34
|
should_execute=should_start_support_container,
|
35
|
-
upstreams=[
|
35
|
+
upstreams=[remove_snake_zrb_app_name_container],
|
36
36
|
cwd=RESOURCE_DIR,
|
37
37
|
setup_cmd=activate_support_compose_profile,
|
38
|
-
compose_cmd="logs",
|
39
|
-
compose_flags=["-f"],
|
40
38
|
compose_env_prefix="CONTAINER_ZRB_ENV_PREFIX",
|
41
39
|
compose_service_configs=snake_zrb_app_name_service_configs,
|
42
40
|
env_files=[compose_env_file],
|
@@ -132,12 +132,81 @@ If you want to run PascalZrbAppName on containers, you will also need `Docker` w
|
|
132
132
|
|
133
133
|
You will also need `Pulumi` if you want to deploy PascalZrbAppName into your Kubernetes cluster.
|
134
134
|
|
135
|
+
# High Level Architecture
|
136
|
+
|
137
|
+
PascalZrbAppName heavily uses dependency inversion and avoids dependency injection on the same time.
|
138
|
+
|
139
|
+
This architecture aims to let the developers define and choose new implementations without breaking any existing part.
|
140
|
+
|
141
|
+
To achieve this, we use two elements:
|
142
|
+
|
143
|
+
- __Component__: Containing interface and implementation
|
144
|
+
- __Integration__: Instantiation of the components. Here is where you choose which component implementation to use and how we tailor the implementations.
|
145
|
+
|
146
|
+
Let's see the following example.
|
147
|
+
|
148
|
+
```
|
149
|
+
┌────────────────────────────────────────────┐
|
150
|
+
│ Component │
|
151
|
+
│ ┌───────────────┐ ┌────────────────┐ │
|
152
|
+
│ │ Messagebus │ │ RPC Caller │ │
|
153
|
+
│ │ ┌────────┐ │ │ ┌──────────┐ │ │
|
154
|
+
│ │ │Kafka │ ├─────┼──►│Messagebus├─┼─┼────┐
|
155
|
+
│ │ └────────┘ │ │ └──────────┘ │ │ │
|
156
|
+
│ │ ┌────────┐ │ │ ┌──────────┐ │ │ │
|
157
|
+
┌──┼───┼───┤Rabbitmq│ │ │ │Grpc │ │ │ │
|
158
|
+
│ │ │ └────────┘ │ │ └──────────┘ │ │ │
|
159
|
+
│ │ │ ┌────────┐ │ └────────────────┘ │ │
|
160
|
+
│ │ │ │Other │ ├──┐ │ │
|
161
|
+
│ │ │ └────────┘ │ │ ┌────────────────┐ │ │
|
162
|
+
│ │ └───────────────┘ │ │ RPC Server │ │ │
|
163
|
+
│ │ │ │ ┌──────────┐ │ │ │
|
164
|
+
│ │ └──┼──►│Messagebus├─┼─┼─┐ │
|
165
|
+
│ │ │ └──────────┘ │ │ │ │
|
166
|
+
│ │ │ ┌──────────┐ │ │ │ │
|
167
|
+
│ │ │ │Grpc │ │ │ │ │
|
168
|
+
│ │ │ └──────────┘ │ │ │ │
|
169
|
+
│ │ └────────────────┘ │ │ │
|
170
|
+
│ └────────────────────────────────────────────┘ │ │
|
171
|
+
│ │ │
|
172
|
+
│ ┌────────────────────────────────────────────┐ │ │
|
173
|
+
│ │ Integration │ │ │
|
174
|
+
│ │ ┌──────────┐ │ │ │
|
175
|
+
└──┼─►│Messagebus├───────┬──────────────┐ │ │ │
|
176
|
+
│ └──────────┘ │ │ │ │ │
|
177
|
+
│ ┌────▼─────┐ ┌─────▼────┐ │ │ │
|
178
|
+
│ │RPC Caller│ │RPC Server│◄─┼─┘ │
|
179
|
+
│ └────▲─────┘ └──────────┘ │ │
|
180
|
+
└─────────────────────┼──────────────────────┘ │
|
181
|
+
└───────────────────────────┘
|
182
|
+
```
|
183
|
+
|
184
|
+
__Components__
|
185
|
+
|
186
|
+
In the example, there are three component interfaces:
|
187
|
+
- `Messagebus`
|
188
|
+
- `RPC Caller`
|
189
|
+
- `RPC Server`
|
190
|
+
|
191
|
+
Each interface has several implementations, for example there are two implementation of `RPC Caller`:
|
192
|
+
- `RPCCaller.Messagebus`: RPC Caller implementation that need `Messagebus`.
|
193
|
+
- `RPCCaller.Grpc`: RPC Caller through GRPC, doesn't need any other component.
|
194
|
+
|
195
|
+
__Integration__
|
196
|
+
|
197
|
+
As for integration, we need to choose particular component implementations.
|
198
|
+
|
199
|
+
- `Messagebus`: For Messagebus, we choose `Messagebus.Rabbitmq` component.
|
200
|
+
- `RPC Caller`: For RPC Caller, we choose `RPCCaller.Messasgebus`. This implementation need a `Messagebus` interface.
|
201
|
+
- `RPC Server`: For RPC Server, we choose `RPCServer.Messasgebus`. This implementation need a `Messagebus` interface.
|
202
|
+
|
203
|
+
|
135
204
|
# Directory Structure
|
136
205
|
|
137
206
|
- `docker-compose.yml`: A multi-profile docker-compose file. This helps you to run your application as a monolith/microservices.
|
138
207
|
- `all-module-disabled.env`: Feature flags to be used when you deactivate all modules.
|
139
208
|
- `all-module-enabled.env`: Feature flags to be used when you activate all modules.
|
140
|
-
- `deployment/`: Deployment directory. By default, we put deployment along with the source code to make it easier to maintain/manage. You can later move your deployments to another repository if you
|
209
|
+
- `deployment/`: Deployment directory. By default, we put deployment along with the source code to make it easier to maintain/manage. You can later move your deployments to another repository if you need to do so.
|
141
210
|
- `/helm-charts`: Helm charts for Rabbitmq, Redpanda, and Postgre.
|
142
211
|
- `__main__.py`: Main Pulumi script.
|
143
212
|
- `template.env`: Default configuration for deployment
|
@@ -187,12 +256,19 @@ You will also need `Pulumi` if you want to deploy PascalZrbAppName into your Kub
|
|
187
256
|
|
188
257
|
# Decisions and Constraints
|
189
258
|
|
259
|
+
## Dependency Inversion without Dependency Injection
|
260
|
+
|
261
|
+
We tend to avoid magical dependency inversion unless necessary. We want PascalZrbEntityName to be as explicit as possible. We do this by providing two elements:
|
262
|
+
|
263
|
+
- Component: Containing all interfaces and implementations
|
264
|
+
- Integration: Instantiation of components. This is where we choose and tailor the component's implementation.
|
265
|
+
|
190
266
|
## Frontend
|
191
|
-
|
267
|
+
PascalZrbAppName's front end serves static files built before runtime (not SSR/Server Side Rendering). That's mean.
|
192
268
|
- The SEO is probably not good.
|
193
269
|
- The page load is sensibly good.
|
194
270
|
- We use Svelte for Frontend because it is easier to read/learn compared to React, Vue, or Angular.
|
195
|
-
- At the moment, the
|
271
|
+
- At the moment, the front end use:
|
196
272
|
- Sveltekit
|
197
273
|
- TailwindCSS
|
198
274
|
- DaisyUI
|
@@ -203,7 +279,7 @@ You will also need `Pulumi` if you want to deploy PascalZrbAppName into your Kub
|
|
203
279
|
- Database connection
|
204
280
|
- Database migration
|
205
281
|
- Data manipulation
|
206
|
-
- To create a custom database implementation, you
|
282
|
+
- To create a custom database implementation, you must create one that complies with `core.repo.Repo`.
|
207
283
|
|
208
284
|
## Messaging
|
209
285
|
|
@@ -215,11 +291,11 @@ You will also need `Pulumi` if you want to deploy PascalZrbAppName into your Kub
|
|
215
291
|
- No messaging platform, a.k.a: in memory. This will only work properly if you run PascalZrbAppName as a monolith.
|
216
292
|
- `APP_BROKER_TYPE=mock`
|
217
293
|
- To create custom event handlers, you need to implement two interfaces:
|
218
|
-
- `
|
219
|
-
- `
|
294
|
+
- `component.messagebus.Publisher`
|
295
|
+
- `component.messagebus.Server`
|
220
296
|
|
221
297
|
## RPC
|
222
298
|
|
223
299
|
- Currently, RPC implementation depends on the messaging platforms. It is possible to override this behavior by creating you custom implementation. There are two interfaces you need to override:
|
224
|
-
- `
|
225
|
-
- `
|
300
|
+
- `component.rpc.Caller`
|
301
|
+
- `component.rpc.Server`
|
@@ -2,9 +2,7 @@ import os
|
|
2
2
|
|
3
3
|
from locust import HttpUser, between, task
|
4
4
|
|
5
|
-
access_token_cookie_key = os.getenv(
|
6
|
-
"PUBLIC_AUTH_ACCESS_TOKEN_COOKIE_KEY", "access_token"
|
7
|
-
)
|
5
|
+
access_token_cookie_key = os.getenv("APP_AUTH_ACCESS_TOKEN_COOKIE_KEY", "access_token")
|
8
6
|
admin_username = os.getenv("APP_AUTH_ADMIN_USERNAME", "root")
|
9
7
|
admin_password = os.getenv("APP_AUTH_ADMIN_PASSWORD", "toor")
|
10
8
|
|
@@ -4,100 +4,98 @@ from typing import List
|
|
4
4
|
|
5
5
|
from helper.conversion import str_to_boolean, str_to_logging_level
|
6
6
|
|
7
|
-
|
7
|
+
APP_SRC_DIR = os.path.dirname(__file__)
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
app_port = int(os.getenv("APP_PORT", "8080"))
|
13
|
-
app_reload = str_to_boolean(os.getenv("APP_RELOAD", "true"))
|
14
|
-
app_max_not_ready = int(os.getenv("APP_MAX_NOT_READY", "10"))
|
9
|
+
APP_NAME = os.getenv("APP_NAME", "app")
|
10
|
+
APP_BRAND = os.getenv("PUBLIC_BRAND", "PascalZrbAppName")
|
11
|
+
APP_TITLE = os.getenv("PUBLIC_TITLE", "PascalZrbAppName")
|
15
12
|
|
16
|
-
|
17
|
-
|
13
|
+
APP_LOGGING_LEVEL = str_to_logging_level(os.getenv("APP_LOGGING_LEVEL", "INFO"))
|
14
|
+
APP_HOST = os.getenv("APP_HOST", "0.0.0.0")
|
15
|
+
APP_PORT = int(os.getenv("APP_PORT", "8080"))
|
16
|
+
APP_RELOAD = str_to_boolean(os.getenv("APP_RELOAD", "true"))
|
17
|
+
APP_MAX_NOT_READY = int(os.getenv("APP_MAX_NOT_READY", "10"))
|
18
|
+
|
19
|
+
APP_ENABLE_OTEL = str_to_boolean(os.getenv("APP_ENABLE_OTEL", "false"))
|
20
|
+
APP_OTEL_EXPORTER_OTLP_ENDPOINT = os.getenv(
|
18
21
|
"APP_OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4317"
|
19
22
|
)
|
20
23
|
|
21
|
-
|
22
|
-
"
|
24
|
+
APP_AUTH_ACCESS_TOKEN_COOKIE_KEY = os.getenv(
|
25
|
+
"APP_AUTH_ACCESS_TOKEN_COOKIE_KEY", "access_token"
|
23
26
|
)
|
24
|
-
|
25
|
-
"
|
27
|
+
APP_AUTH_REFRESH_TOKEN_COOKIE_KEY = os.getenv(
|
28
|
+
"APP_AUTH_REFRESH_TOKEN_COOKIE_KEY", "refresh_token"
|
26
29
|
)
|
27
30
|
|
28
|
-
|
29
|
-
|
31
|
+
APP_AUTH_ACCESS_TOKEN_TYPE = os.getenv("APP_AUTH_ACCESS_TOKEN_TYPE", "jwt")
|
32
|
+
APP_AUTH_ACCESS_TOKEN_EXPIRE_SECONDS = int(
|
30
33
|
os.getenv("APP_AUTH_ACCESS_TOKEN_EXPIRE_SECONDS", "300")
|
31
34
|
)
|
32
|
-
|
33
|
-
|
35
|
+
APP_AUTH_REFRESH_TOKEN_TYPE = os.getenv("APP_AUTH_REFRESH_TOKEN_TYPE", "jwt")
|
36
|
+
APP_AUTH_REFRESH_TOKEN_EXPIRE_SECONDS = int(
|
34
37
|
os.getenv("APP_AUTH_REFRESH_TOKEN_EXPIRE_SECONDS", "86400")
|
35
38
|
)
|
36
|
-
|
37
|
-
|
39
|
+
APP_AUTH_JWT_TOKEN_SECRET_KEY = os.getenv("APP_AUTH_JWT_TOKEN_SECRET_KEY", "secret")
|
40
|
+
APP_AUTH_JWT_TOKEN_ALGORITHM = os.getenv("APP_AUTH_JWT_TOKEN_ALGORITHM", "HS256")
|
41
|
+
|
42
|
+
APP_AUTH_ADMIN_ACTIVE = str_to_boolean(os.getenv("APP_AUTH_ADMIN_ACTIVE", "true"))
|
43
|
+
APP_AUTH_ADMIN_USER_ID = os.getenv("APP_AUTH_ADMIN_USER_ID", "root")
|
44
|
+
APP_AUTH_ADMIN_USERNAME = os.getenv("APP_AUTH_ADMIN_USERNAME", "admin")
|
45
|
+
APP_AUTH_ADMIN_PASSWORD = os.getenv("APP_AUTH_ADMIN_PASSWORD", "admin")
|
46
|
+
APP_AUTH_ADMIN_EMAIL = os.getenv("APP_AUTH_ADMIN_EMAIL", "")
|
47
|
+
APP_AUTH_ADMIN_PHONE = os.getenv("APP_AUTH_ADMIN_PHONE", "")
|
48
|
+
APP_AUTH_GUEST_USER_ID = os.getenv("APP_AUTH_GUEST_USER_ID", "guest")
|
49
|
+
APP_AUTH_GUEST_USERNAME = os.getenv("APP_AUTH_GUEST_USERNAME", "guest")
|
50
|
+
APP_AUTH_GUEST_EMAIL = os.getenv("APP_AUTH_GUEST_EMAIL", "")
|
51
|
+
APP_AUTH_GUEST_PHONE = os.getenv("APP_AUTH_GUEST_PHONE", "")
|
38
52
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
app_auth_guest_user_id = os.getenv("APP_AUTH_GUEST_USER_ID", "guest")
|
46
|
-
app_auth_guest_username = os.getenv("APP_AUTH_GUEST_USERNAME", "guest")
|
47
|
-
app_auth_guest_email = os.getenv("APP_AUTH_GUEST_EMAIL", "")
|
48
|
-
app_auth_guest_phone = os.getenv("APP_AUTH_GUEST_PHONE", "")
|
53
|
+
APP_DB_CONNECTION = os.getenv("APP_DB_CONNECTION", "sqlite://")
|
54
|
+
APP_DB_ENGINE_SHOW_LOG = str_to_boolean(os.getenv("APP_DB_ENGINE_SHOW_LOG", "false"))
|
55
|
+
APP_DB_AUTO_MIGRATE = str_to_boolean(os.getenv("APP_DB_AUTO_MIGRATE", "true"))
|
56
|
+
APP_DB_POOL_PRE_PING = str_to_boolean(os.getenv("APP_DB_POOL_PRE_PING", "true"))
|
57
|
+
APP_DB_POOL_SIZE = int(os.getenv("APP_DB_POOL_SIZE", "20"))
|
58
|
+
APP_DB_POOL_MAX_OVERFLOW = int(os.getenv("APP_DB_POOL_MAX_OVERFLOW", "0"))
|
49
59
|
|
50
|
-
app_db_connection = os.getenv("APP_DB_CONNECTION", "sqlite://")
|
51
|
-
app_db_engine_show_log = str_to_boolean(os.getenv("APP_DB_ENGINE_SHOW_LOG", "false"))
|
52
|
-
app_db_auto_migrate = str_to_boolean(os.getenv("APP_DB_AUTO_MIGRATE", "true"))
|
53
60
|
|
54
|
-
|
61
|
+
APP_BROKER_TYPE = os.getenv("APP_BROKER_TYPE", "mock")
|
55
62
|
|
56
|
-
|
63
|
+
APP_ENABLE_RPC_SERVER: bool = str_to_boolean(os.getenv("APP_ENABLE_RPC_SERVER", "true"))
|
57
64
|
|
58
|
-
|
65
|
+
APP_ENABLE_EVENT_HANDLER: bool = str_to_boolean(
|
59
66
|
os.getenv("APP_ENABLE_EVENT_HANDLER", "true")
|
60
67
|
)
|
61
68
|
|
62
|
-
|
69
|
+
APP_ENABLE_FRONTEND: bool = str_to_boolean(os.getenv("APP_ENABLE_FRONTEND", "true"))
|
63
70
|
|
64
|
-
|
71
|
+
APP_ENABLE_API: bool = str_to_boolean(os.getenv("APP_ENABLE_API", "true"))
|
65
72
|
|
66
|
-
|
73
|
+
APP_RMQ_CONNECTION_STRING = os.getenv(
|
67
74
|
"APP_RMQ_CONNECTION", "amqp://guest:guest@localhost/"
|
68
75
|
)
|
69
76
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
77
|
+
APP_KAFKA_BOOTSTRAP_SERVERS = os.getenv("APP_KAFKA_BOOTSTRAP_SERVERS", "localhost:9092")
|
78
|
+
APP_KAFKA_SECURITY_PROTOCOL = os.getenv("APP_KAFKA_SECURITY_PROTOCOL", "PLAINTEXT")
|
79
|
+
APP_KAFKA_SASL_MECHANISM = os.getenv("APP_KAFKA_SASL_MECHANISM", "SCRAM-SHA-512")
|
80
|
+
APP_KAFKA_SASL_USER = os.getenv("APP_KAFKA_SASL_USER", "admin")
|
81
|
+
APP_KAFKA_SASL_PASS = os.getenv("APP_KAFKA_SASL_PASS", "admin")
|
75
82
|
|
76
|
-
|
83
|
+
APP_CORS_ALLOW_ORIGINS: List[str] = json.loads(
|
77
84
|
os.getenv("APP_CORS_ALLOW_ORIGINS", '["*"]')
|
78
85
|
)
|
79
|
-
|
80
|
-
|
86
|
+
APP_CORS_ALLOW_ORIGIN_REGEX: str = os.getenv("APP_CORS_ALLOW_ORIGIN_REGEX", "")
|
87
|
+
APP_CORS_ALLOW_METHODS: List[str] = json.loads(
|
81
88
|
os.getenv("APP_CORS_ALLOW_METHODS", '["*"]')
|
82
89
|
)
|
83
|
-
|
90
|
+
APP_CORS_ALLOW_HEADERS: List[str] = json.loads(
|
84
91
|
os.getenv("APP_CORS_ALLOW_HEADERS", '["*"]')
|
85
92
|
)
|
86
|
-
|
93
|
+
APP_CORS_ALLOW_CREDENTIALS: bool = str_to_boolean(
|
87
94
|
os.getenv("APP_CORS_ALLOW_CREDENTIALS", "false")
|
88
95
|
)
|
89
|
-
|
96
|
+
APP_CORS_EXPOSE_HEADERS: bool = str_to_boolean(
|
90
97
|
os.getenv("APP_CORS_EXPOSE_HEADERS", "false")
|
91
98
|
)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
public_brand = os.getenv("PUBLIC_BRAND", "PascalZrbAppName")
|
97
|
-
public_title = os.getenv("PUBLIC_TITLE", "PascalZrbAppName")
|
98
|
-
public_auth_access_token_cookie_key = os.getenv(
|
99
|
-
"PUBLIC_AUTH_ACCESS_TOKEN_COOKIE_KEY", "access_token"
|
100
|
-
)
|
101
|
-
public_auth_refresh_token_cookie_key = os.getenv(
|
102
|
-
"PUBLIC_AUTH_REFRESH_TOKEN_COOKIE_KEY", "refresh_token"
|
103
|
-
)
|
99
|
+
APP_CORS_MAX_AGE: int = int(os.getenv("APP_CORS_MAX_AGE", "600"))
|
100
|
+
APP_ENABLE_AUTH_MODULE = str_to_boolean(os.getenv("APP_ENABLE_AUTH_MODULE", "true"))
|
101
|
+
APP_ENABLE_LOG_MODULE = str_to_boolean(os.getenv("APP_ENABLE_LOG_MODULE", "true"))
|
@@ -3,7 +3,7 @@
|
|
3
3
|
import Navigation from '$lib/components/navigation/Navigation.svelte';
|
4
4
|
import { navData } from '$lib/config/navData';
|
5
5
|
import { getBrand, getTitle } from '$lib/config/app';
|
6
|
-
import logo from '
|
6
|
+
import logo from '@static/logo.png';
|
7
7
|
import "../app.css";
|
8
8
|
|
9
9
|
let appBrand = '';
|
zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/frontend/vite.config.ts
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
import { sveltekit } from '@sveltejs/kit/vite';
|
2
2
|
import { defineConfig } from 'vitest/config';
|
3
|
+
import path from 'path';
|
3
4
|
|
4
5
|
export default defineConfig({
|
5
6
|
plugins: [sveltekit()],
|
6
7
|
test: {
|
7
8
|
include: ['src/**/*.{test,spec}.{js,ts}']
|
8
|
-
}
|
9
|
+
},
|
10
|
+
resolve: {
|
11
|
+
alias: {
|
12
|
+
'@static': path.resolve(__dirname, 'static'),
|
13
|
+
},
|
14
|
+
},
|
9
15
|
});
|
zrb/builtin/project/add/fastapp/app/template/src/kebab-zrb-app-name/src/integration/app/__init__.py
ADDED
File without changes
|