Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ RUN pip install --no-cache-dir pdm && \
rm /tmp/req.txt

COPY . .
RUN chmod +x load_envs.sh
RUN chmod +x tools/load_envs.sh

ENV ENV=prod
ENV PYTHONPATH=src

CMD ["./load_envs.sh", "python", "-u", "-m", "gateway.server"]
CMD ["./tools/load_envs.sh", "python", "-u", "-m", "apigateway.server"]
93 changes: 0 additions & 93 deletions Makefile

This file was deleted.

37 changes: 37 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
set windows-shell := ["sh", "-c"]
set dotenv-load := true

COMMON_JUST_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/main/api-gateway/common.just'
LOAD_ENVS_URL := 'https://raw.githubusercontent.com/esclient/tools/refs/heads/main/load_envs.sh'

PROTO_REPO := 'https://raw.githubusercontent.com/esclient/protos'

COMMENT_PROTO_TAG := 'v0.0.8'
COMMENT_PROTO_NAME := 'comment.proto'

USER_PROTO_TAG := 'v0.0.8'
USER_PROTO_NAME := 'user.proto'

RATING_PROTO_TAG := 'v0.0.15'
RATING_PROTO_NAME := 'rating.proto'

MOD_PROTO_TAG := 'v0.1.2'
MOD_PROTO_NAME := 'mod.proto'

TMP_DIR := '.proto'
OUT_DIR := 'src/apigateway/stubs'

MKDIR_TOOLS := 'mkdir -p tools'

FETCH_COMMON_JUST := 'curl -fsSL ' + COMMON_JUST_URL + ' -o tools/common.just'
FETCH_LOAD_ENVS := 'curl -fsSL ' + LOAD_ENVS_URL + ' -o tools/load_envs.sh'

import? 'tools/common.just'

default:
@just --list

fetch-tools:
{{ MKDIR_TOOLS }}
{{ FETCH_COMMON_JUST }}
{{ FETCH_LOAD_ENVS }}
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exclude = '''
| venv
| build
| dist
| src/gateway/stubs
| src/apigateway/stubs
)/
'''

Expand All @@ -26,29 +26,29 @@ include_trailing_comma = true
force_grid_wrap = 0
use_parentheses = true
ensure_newline_before_comments = true
skip = [".venv", "src/gateway/stubs"]
skip = [".venv", "src/apigateway/stubs"]

[tool.flake8]
max-line-length = 120
extend-ignore = ["E203", "W503", "E501"]
per-file-ignores = [
"__init__.py:F401",
"tests/*:T20,ARG001",
"src/gateway/stubs/*:E501,ARG001,ARG002"
"src/apigateway/stubs/*:E501,ARG001,ARG002"
]
exclude = [
".venv",
"__pycache__",
"build",
"dist",
"src/gateway/stubs",
"src/apigateway/stubs",
]

[tool.ruff]
line-length = 120
target-version = "py313"
preview = true
exclude = [".venv", "build", "dist", "src/gateway/stubs"]
exclude = [".venv", "build", "dist", "src/apigateway/stubs"]

[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -77,8 +77,8 @@ extend-ignore = [

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["T20", "ARG001"]
"src/gateway/resolvers/*" = ["ARG001", "ARG002"]
"src/gateway/stubs/*" = ["E501","ARG001", "ARG002"]
"src/apigateway/resolvers/*" = ["ARG001", "ARG002"]
"src/apigateway/stubs/*" = ["E501","ARG001", "ARG002"]

[tool.mypy]
python_version = "3.13"
Expand All @@ -97,7 +97,7 @@ mypy_path = ["src"]
plugins = ["pydantic.mypy"]

[[tool.mypy.overrides]]
module = ["gateway.stubs.*"]
module = ["apigateway.stubs.*"]
ignore_errors = true

[project]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import logging
from typing import Self
from collections.abc import Awaitable, Callable
from typing import Self

import grpc
import grpc.aio
from google.protobuf import message as _message

from ..helpers.retry import grpc_retry
from apigateway.helpers.retry import grpc_retry

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import grpc

from gateway.clients.comment import CommentServiceClient
from gateway.clients.mod import ModServiceClient
from gateway.clients.rating import RatingServiceClient
from apigateway.clients.comment import CommentServiceClient
from apigateway.clients.mod import ModServiceClient
from apigateway.clients.rating import RatingServiceClient


class GrpcClientFactory:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@


from gateway.stubs import comment_pb2, comment_pb2_grpc

from .base_client import GrpcClient
from apigateway.clients.base_client import GrpcClient
from apigateway.stubs.comment import comment_pb2, comment_pb2_grpc


class CommentServiceClient(GrpcClient):
Expand Down
7 changes: 2 additions & 5 deletions src/gateway/clients/mod.py → src/apigateway/clients/mod.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@


from gateway.stubs import mod_pb2, mod_pb2_grpc

from .base_client import GrpcClient
from apigateway.clients.base_client import GrpcClient
from apigateway.stubs.mod import mod_pb2, mod_pb2_grpc


class ModServiceClient(GrpcClient):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@


from gateway.stubs import rating_pb2, rating_pb2_grpc

from .base_client import GrpcClient
from apigateway.clients.base_client import GrpcClient
from apigateway.stubs.rating import rating_pb2, rating_pb2_grpc


class RatingServiceClient(GrpcClient):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from enum import StrEnum
from typing import Final

from gateway.stubs.mod_pb2 import ModStatus as ProtoModStatus
from apigateway.stubs.mod.mod_pb2 import ModStatus as ProtoModStatus


class GraphQLModStatus(StrEnum):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from gateway.clients.base_client import GrpcClient
from apigateway.clients.base_client import GrpcClient


class GQLContextViewer:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from graphql import GraphQLResolveInfo
from pydantic import BaseModel, field_validator

from gateway.helpers.id_helper import validate_and_convert_id
from apigateway.helpers.id_helper import validate_and_convert_id

from ..grpc_error_wrapper import handle_grpc_errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from graphql import GraphQLResolveInfo
from pydantic import BaseModel, field_validator

from gateway.helpers.id_helper import validate_and_convert_id
from apigateway.helpers.id_helper import validate_and_convert_id

from ..grpc_error_wrapper import handle_grpc_errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from graphql import GraphQLResolveInfo
from pydantic import BaseModel, field_validator

from gateway.helpers.id_helper import validate_and_convert_id
from apigateway.helpers.id_helper import validate_and_convert_id

from ..grpc_error_wrapper import handle_grpc_errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from graphql import GraphQLResolveInfo
from pydantic import BaseModel, field_validator

from gateway.helpers.id_helper import validate_and_convert_id
from apigateway.helpers.id_helper import validate_and_convert_id

from ..grpc_error_wrapper import handle_grpc_errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from graphql import GraphQLResolveInfo
from pydantic import BaseModel, field_validator

from gateway.converters.mod_status_converter import proto_to_graphql_mod_status
from gateway.helpers.id_helper import validate_and_convert_id
from apigateway.converters.mod_status_converter import proto_to_graphql_mod_status
from apigateway.helpers.id_helper import validate_and_convert_id

from ..grpc_error_wrapper import handle_grpc_errors

Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions src/gateway/server.py → src/apigateway/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from ariadne.asgi import GraphQL
from ariadne.explorer import ExplorerGraphiQL

from gateway.clients.client_factory import GrpcClientFactory
from gateway.resolvers.mutation.comment import comment_mutation
from gateway.resolvers.mutation.mod import mod_mutation
from gateway.resolvers.mutation.root import mutation
from gateway.resolvers.query.comment import comment_query
from gateway.resolvers.query.mod import mod_query
from gateway.resolvers.query.root import query
from gateway.settings import Settings
from apigateway.clients.client_factory import GrpcClientFactory
from apigateway.resolvers.mutation.comment import comment_mutation
from apigateway.resolvers.mutation.mod import mod_mutation
from apigateway.resolvers.mutation.root import mutation
from apigateway.resolvers.query.comment import comment_query
from apigateway.resolvers.query.mod import mod_query
from apigateway.resolvers.query.root import query
from apigateway.settings import Settings

from .esclient_graphql import GQLContextViewer

Expand All @@ -22,7 +22,7 @@

settings = Settings()

type_defs = load_schema_from_path("src/gateway/schema")
type_defs = load_schema_from_path("src/apigateway/schema")

schema = make_executable_schema(
type_defs,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings
Expand Down
Empty file.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import warnings
Expand Down
Empty file.
Loading
Loading