diff --git a/Dockerfile b/Dockerfile index 20283c5..83b71bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,6 @@ RUN pip install -U pip && \ WORKDIR /app -ENTRYPOINT [ "python", "./start_grpc_server.py" ] +ENTRYPOINT [ "python", "-m", "start_grpc_server" ] COPY . ./ diff --git a/poetry.lock b/poetry.lock index 70b4059..ed3298c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1208,13 +1208,13 @@ sqlcipher = ["sqlcipher3_binary"] [[package]] name = "sslog" -version = "0.0.0a45" +version = "0.0.0a47" description = "opinionated logger based on structlog" optional = false python-versions = "~=3.8" files = [ - {file = "sslog-0.0.0a45-py3-none-any.whl", hash = "sha256:fe4777e90c9caba57af183db6eed7d0ba797da829e5f4acb920c32a7b9ed54f3"}, - {file = "sslog-0.0.0a45.tar.gz", hash = "sha256:169e17e5fdc7f302fe0e33b94cb22a2cf8f2f296899ed6c239a643de5b3847d0"}, + {file = "sslog-0.0.0a47-py3-none-any.whl", hash = "sha256:f77bb238acaf56116fc1606ffe1c9e7e7f6d9db627f2d716dfe6bd802527982f"}, + {file = "sslog-0.0.0a47.tar.gz", hash = "sha256:2590a7b02d2b7dc6b3db014a89281330a6a7314b6bf54b1a3c64dcbaded79350"}, ] [package.dependencies] @@ -1226,13 +1226,13 @@ dev = ["colorama", "loguru", "mypy", "pre-commit", "rich"] [[package]] name = "starlette" -version = "0.38.5" +version = "0.38.6" description = "The little ASGI library that shines." optional = false python-versions = ">=3.8" files = [ - {file = "starlette-0.38.5-py3-none-any.whl", hash = "sha256:632f420a9d13e3ee2a6f18f437b0a9f1faecb0bc42e1942aa2ea0e379a4c4206"}, - {file = "starlette-0.38.5.tar.gz", hash = "sha256:04a92830a9b6eb1442c766199d62260c3d4dc9c4f9188360626b1e0273cb7077"}, + {file = "starlette-0.38.6-py3-none-any.whl", hash = "sha256:4517a1409e2e73ee4951214ba012052b9e16f60e90d73cfb06192c19203bbb05"}, + {file = "starlette-0.38.6.tar.gz", hash = "sha256:863a1588f5574e70a821dadefb41e4881ea451a47a3cd1b4df359d4ffefe5ead"}, ] [package.dependencies] @@ -1603,4 +1603,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "104561027d63d90c63a003e06bb4a1fdc6ece7baec1e9f5e1f26a23fb46fdf06" +content-hash = "60071f5e6d6a5289b4f661eebf1e513334898a3ee8d8727bd68eb9ca3fe3930f" diff --git a/pyproject.toml b/pyproject.toml index 30cadfc..1124079 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,12 +14,12 @@ pymysql = "1.1.1" pydantic = "2.9.2" pydantic-settings = "2.5.2" typing-extensions = '4.12.2' -sslog = "0.0.0a45" +sslog = "0.0.0a47" protobuf = "5.27.2" ariadne = "^0.23.0" uvicorn = { version = "^0.30.6", extras = ['standard'] } aiomysql = "^0.2.0" -six = "^1.16.0" +six = "1.16.0" [tool.poetry.group.dev.dependencies] sqlacodegen = "3.0.0rc5" diff --git a/rpc/timeline_service.py b/rpc/timeline_service.py index e407a95..42eb8d4 100644 --- a/rpc/timeline_service.py +++ b/rpc/timeline_service.py @@ -193,7 +193,7 @@ def __episode_collect(self, req: EpisodeCollectRequest) -> EpisodeCollectRespons ) if tl and tl.created_at >= int(time.time() - 15 * 60): - logger.info("find previous timeline, updating") + logger.info("find previous timeline, updating", user_id=req.user_id) if ( tl.cat == TimelineCat.Progress and tl.type == tlType @@ -263,7 +263,7 @@ def __subject_progress( ) if tl and tl.created_at >= int(time.time() - 15 * 60): - logger.info("find previous timeline, updating") + logger.info("find previous timeline, updating", user_id=req.user_id) if ( tl.cat == TimelineCat.Progress and tl.type == tlType diff --git a/scripts/grpc_client.py b/scripts/grpc_client.py index 8a05d4f..8b3ad29 100644 --- a/scripts/grpc_client.py +++ b/scripts/grpc_client.py @@ -1,41 +1,16 @@ import grpc +from sslog import logger from api.v1 import timeline_pb2_grpc -from api.v1.timeline_pb2 import ( - Episode, - EpisodeCollectRequest, - EpisodeCollectResponse, - Subject, -) +from api.v1.timeline_pb2 import HelloRequest +from chii.config import config def run() -> None: - print("Will try to greet world ...") - with grpc.insecure_channel("127.0.0.1:5000") as channel: + logger.info("healthy check") + with grpc.insecure_channel(f"127.0.0.1:{config.grpc_port}") as channel: stub = timeline_pb2_grpc.TimeLineServiceStub(channel) - response: EpisodeCollectResponse = stub.EpisodeCollect( - EpisodeCollectRequest( - user_id=100, - last=Episode( - name_cn="22", - type=1, - name="name", - id=1, - sort=1.4, - ), - subject=Subject( - id=88, - name="nn", - image="image image", - type=2, - name_cn="name cn", - series=False, - eps_total=0, - vols_total=0, - ), - ) - ) - print("Greeter client received:", response.ok) + stub.Hello(HelloRequest(name="client")) if __name__ == "__main__":