Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into issue-4-refactor-link…
Browse files Browse the repository at this point in the history
…-strategy
  • Loading branch information
Sergio García Prado committed Dec 30, 2021
2 parents 7e5c307 + cdb46db commit d4872f9
Show file tree
Hide file tree
Showing 65 changed files with 123 additions and 142 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

build:
rm -rf .build
sh build.sh
sh build.sh
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ tar -czf "$BUILD_DIR/project-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/project

echo "Building Project Discovery Minos Init Template..."
tar -czf "$BUILD_DIR/project-discovery-minos-init.tar.gz" -C "$ROOT_DIR/project/discovery/minos/init" .

echo "Building Project Discovery Minos Deploy Docker Compose Template..."
tar -czf "$BUILD_DIR/project-discovery-minos-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/project/discovery/minos/deploy/docker-compose" .

Expand All @@ -95,4 +95,4 @@ echo "Building Project Deploy Docker Compose Template..."
tar -czf "$BUILD_DIR/project-deploy-docker-compose.tar.gz" -C "$ROOT_DIR/project/deploy/docker-compose" .

echo "Building Project Deploy Kubernetes Template..."
tar -czf "$BUILD_DIR/project-deploy-kubernetes.tar.gz" -C "$ROOT_DIR/project/deploy/kubernetes" .
tar -czf "$BUILD_DIR/project-deploy-kubernetes.tar.gz" -C "$ROOT_DIR/project/deploy/kubernetes" .
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.venv
*.lmdb
dist/
dist/
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.venv
*.lmdb
dist/
dist/
2 changes: 1 addition & 1 deletion microservice/language/python/deploy/kubernetes/copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ _envops:
_templates_suffix: .jinja

_tasks:
- make -s deploy
- make -s deploy
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ spec:
- containerPort: 8080
envFrom:
- configMapRef:
name: {{ kubernetes_config }}
name: {{ kubernetes_config }}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
ports:
- port: 8080
selector:
app.kubernetes.io/name: microservice-{{ name }}
app.kubernetes.io/name: microservice-{{ name }}
2 changes: 1 addition & 1 deletion microservice/language/python/init/Makefile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ coverage:
poetry run coverage xml

create-database:
$(MAKE) -C ../../external/postgres create-database DB_NAME={{ name }}_db
$(MAKE) -C ../../external/postgres create-database DB_NAME={{ name }}_db
2 changes: 1 addition & 1 deletion microservice/language/python/init/copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ _envops:
_templates_suffix: .jinja

_tasks:
- make -s create-database
- make -s create-database
23 changes: 10 additions & 13 deletions microservice/language/python/init/src/cli.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
import logging
import sys
from pathlib import (
Path,
)
Path, )
from typing import (
Optional,
)
Optional, )

import typer

from minos.common import (
EntrypointLauncher,
)
EntrypointLauncher, )

logging.getLogger("aiohttp.access").setLevel(logging.WARNING)

app = typer.Typer()


@app.command("start")
def start(
file_path: Optional[Path] = typer.Argument(
"config.yml", help="Microservice configuration file.", envvar="MINOS_CONFIGURATION_FILE_PATH",
)
):
def start(file_path: Optional[Path] = typer.Argument(
"config.yml",
help="Microservice configuration file.",
envvar="MINOS_CONFIGURATION_FILE_PATH",
)):
"""Start the microservice."""
launcher = EntrypointLauncher.from_config(file_path, external_modules=[sys.modules["src"]])
launcher = EntrypointLauncher.from_config(
file_path, external_modules=[sys.modules["src"]])
launcher.launch()


Expand Down
41 changes: 15 additions & 26 deletions microservice/language/python/init/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
from __future__ import (
annotations,
)
annotations, )

from pathlib import (
Path,
)
Path, )
from typing import (
Optional,
)
from uuid import (
UUID,
uuid4,
)

from minos.common import (
CommandReply,
DependencyInjector,
InMemoryRepository,
InMemorySnapshot,
MinosBroker,
MinosConfig,
MinosSagaManager,
Model,
)
Optional, )
from uuid import UUID
from uuid import uuid4

from minos.common import CommandReply
from minos.common import DependencyInjector
from minos.common import InMemoryRepository
from minos.common import InMemorySnapshot
from minos.common import MinosBroker
from minos.common import MinosConfig
from minos.common import MinosSagaManager
from minos.common import Model
from minos.networks import (
Request,
)
Request, )


class _FakeRequest(Request):
"""For testing purposes"""

def __init__(self, content):
super().__init__()
self._content = content
Expand All @@ -54,14 +45,12 @@ def __repr__(self) -> str:

class _FakeBroker(MinosBroker):
"""For testing purposes."""

async def send(self, items: list[Model], **kwargs) -> None:
"""For testing purposes."""


class _FakeSagaManager(MinosSagaManager):
"""For testing purposes."""

async def _run_new(self, name: str, **kwargs) -> UUID:
"""For testing purposes."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ minos-microservice-networks~=0.3.2
minos-microservice-aggregate~=0.2.2
minos-microservice-saga~=0.3.5
minos-microservice-cqrs~=0.2.1
typer~=0.3.2
typer~=0.3.2
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ _envops:
_templates_suffix: .jinja

_tasks:
- make -s lock
- make -s lock
14 changes: 6 additions & 8 deletions project/apigateway/minos/deploy/docker-compose/_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations
from __future__ import (
annotations, )

from pathlib import Path
from pathlib import (
Path, )

import yaml

Expand All @@ -17,12 +19,8 @@ def build_docker_compose(path: Path) -> str:
container = {
"restart": "always",
"build": "external/apigateway",
"ports": [
"5566"
],
"depends_on": [
"discovery"
],
"ports": ["5566"],
"depends_on": ["discovery"],
"environment": {
"PYTHONPATH": "/api_gateway",
"DISCOVERY_SERVICE_HOST": "discovery",
Expand Down
2 changes: 1 addition & 1 deletion project/apigateway/minos/deploy/docker-compose/copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ _exclude:
- "_utils.py"

_functions:
- "_utils.build_docker_compose"
- "_utils.build_docker_compose"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ build_docker_compose(destination / "docker-compose.yml") }}
{{ build_docker_compose(destination / "docker-compose.yml") }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ FROM python
RUN pip install minos-apigateway==0.1.0

COPY config.yml ./config.yml
CMD ["api_gateway", "start", "config.yml"]
CMD ["api_gateway", "start", "config.yml"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ rest:
cors:
enabled: true
auth:
host: localhost
port: 8092
method: POST
path: /validate-token
host: localhost
port: 8092
method: POST
path: /validate-token
discovery:
host: localhost
port: 5567
port: 5567
2 changes: 1 addition & 1 deletion project/apigateway/minos/deploy/kubernetes/copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ _envops:
_templates_suffix: .jinja

_tasks:
- make -s -C external/apigateway deploy
- make -s -C external/apigateway deploy
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ data:
API_GATEWAY_REST_PORT: "5566"
API_GATEWAY_DISCOVERY_PORT: "5567"
API_GATEWAY_DISCOVERY_HOST: "minos-discovery.{{ project_name }}.svc.cluster.local"
API_GATEWAY_REST_AUTH_ENABLED: "false"
API_GATEWAY_REST_AUTH_ENABLED: "false"
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ spec:
- containerPort: 5566
envFrom:
- configMapRef:
name: apigateway-config
name: apigateway-config
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ spec:
service:
name: minos-apigateway
port:
number: 5566
number: 5566
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
ports:
- port: 5566
selector:
app.kubernetes.io/name: minos-apigateway
app.kubernetes.io/name: minos-apigateway
1 change: 0 additions & 1 deletion project/apigateway/minos/deploy/remote/copier.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

_envops:
block_start_string: "{%"
block_end_string: "%}"
Expand Down
14 changes: 6 additions & 8 deletions project/broker/kafka/deploy/docker-compose/_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations
from __future__ import (
annotations, )

from pathlib import Path
from pathlib import (
Path, )

import yaml

Expand All @@ -24,12 +26,8 @@ def build_docker_compose(path: Path) -> str:
kafka_container = {
"restart": "always",
"image": "wurstmeister/kafka:latest",
"ports": [
"9092"
],
"depends_on": [
"zookeeper"
],
"ports": ["9092"],
"depends_on": ["zookeeper"],
"volumes": ["kafka_volume:/kafka"],
"environment": {
"KAFKA_DELETE_TOPIC_ENABLE": "true",
Expand Down
2 changes: 1 addition & 1 deletion project/broker/kafka/deploy/docker-compose/copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ _exclude:
- "_utils.py"

_functions:
- "_utils.build_docker_compose"
- "_utils.build_docker_compose"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ build_docker_compose(destination / "docker-compose.yml") }}
{{ build_docker_compose(destination / "docker-compose.yml") }}
2 changes: 1 addition & 1 deletion project/broker/kafka/deploy/kubernetes/copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ _templates_suffix: .jinja

_tasks:
- make -s -C external/zookeeper deploy
- make -s -C external/kafka deploy
- make -s -C external/kafka deploy
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ metadata:
data:
KAFKA_DELETE_TOPIC_ENABLE: "true"
KAFKA_PORT: "9092"
KAFKA_ZOOKEEPER_CONNECT: "zookeeper.{{ project_name }}.svc.cluster.local:2181"
KAFKA_ZOOKEEPER_CONNECT: "zookeeper.{{ project_name }}.svc.cluster.local:2181"
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ spec:
- name: KAFKA_ADVERTISED_HOST_NAME
valueFrom:
fieldRef:
fieldPath: status.podIP
fieldPath: status.podIP
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
ports:
- port: 9092
selector:
app.kubernetes.io/name: kafka
app.kubernetes.io/name: kafka
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ spec:
image: wurstmeister/zookeeper:latest
imagePullPolicy: Always
ports:
- containerPort: 2181
- containerPort: 2181
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ spec:
ports:
- port: 2181
selector:
app.kubernetes.io/name: zookeeper
app.kubernetes.io/name: zookeeper
1 change: 0 additions & 1 deletion project/broker/kafka/deploy/remote/copier.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

_envops:
block_start_string: "{%"
block_end_string: "%}"
Expand Down
10 changes: 5 additions & 5 deletions project/database/postgres/deploy/docker-compose/_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations
from __future__ import (
annotations, )

from pathlib import Path
from pathlib import (
Path, )

import yaml

Expand All @@ -20,9 +22,7 @@ def build_docker_compose(path: Path) -> str:
"restart": "always",
"build": "external/postgres",
"command": "postgres -c 'max_connections=200'",
"ports": [
"5432"
],
"ports": ["5432"],
"volumes": [
"postgres_volume:/var/lib/postgresql",
],
Expand Down
Loading

0 comments on commit d4872f9

Please sign in to comment.