Skip to content

Commit

Permalink
arch: complete raising application policy level
Browse files Browse the repository at this point in the history
  • Loading branch information
emptybutton committed Jan 14, 2025
1 parent 011b1b8 commit 05db018
Show file tree
Hide file tree
Showing 34 changed files with 194 additions and 256 deletions.
16 changes: 8 additions & 8 deletions docs/system-design/raw.drawio
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" version="25.0.3">
<mxfile host="app.diagrams.net" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36" version="26.0.4">
<diagram id="u57AqEZIpZNnvEgRTM_I" name="Страница — 1">
<mxGraphModel dx="1405" dy="768" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1" pageHeight="1" math="0" shadow="0">
<root>
Expand Down Expand Up @@ -39,7 +39,7 @@
<mxCell id="yebdUftTMpvAP_zZqaQb-86" style="edgeStyle=none;curved=1;rounded=0;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontSize=12;startSize=8;endSize=8;" parent="1" source="4hBZCaStK4hO_Ke5i-zd-49" target="yebdUftTMpvAP_zZqaQb-63" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="4hBZCaStK4hO_Ke5i-zd-49" value="Chunk stream compression&amp;nbsp;&lt;span style=&quot;background-color: initial;&quot;&gt;service&lt;/span&gt;" style="rounded=0;whiteSpace=wrap;html=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fillColor=#6a00ff;strokeColor=#3700CC;align=center;verticalAlign=middle;fontSize=12;fontColor=#000000;fontStyle=1;strokeWidth=1.2;" parent="1" vertex="1">
<mxCell id="4hBZCaStK4hO_Ke5i-zd-49" value="Chunk image&lt;br&gt;&lt;div&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(237, 237, 237));&quot;&gt;refresh&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(237, 237, 237));&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: initial; color: light-dark(rgb(0, 0, 0), rgb(237, 237, 237));&quot;&gt;worker&lt;/span&gt;&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fillColor=#6a00ff;strokeColor=#3700CC;align=center;verticalAlign=middle;fontSize=12;fontColor=#000000;fontStyle=1;strokeWidth=1.2;" parent="1" vertex="1">
<mxGeometry x="-208" y="366" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="4hBZCaStK4hO_Ke5i-zd-84" value="Client" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontStyle=1;fillColor=#ffe41a;strokeColor=#ffd900;fontColor=#000000;gradientColor=none;strokeWidth=1.2;" parent="1" vertex="1">
Expand Down Expand Up @@ -76,7 +76,7 @@
<mxPoint x="-120" y="160" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="yebdUftTMpvAP_zZqaQb-63" value="Chunk image&lt;div&gt;stream offset&lt;/div&gt;" style="whiteSpace=wrap;html=1;aspect=fixed;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontStyle=1" parent="1" vertex="1">
<mxCell id="yebdUftTMpvAP_zZqaQb-63" value="Chunk image&lt;br&gt;&lt;div&gt;&lt;span style=&quot;background-color: transparent; color: light-dark(rgb(0, 0, 0), rgb(237, 237, 237));&quot;&gt;refresh&lt;/span&gt;&lt;/div&gt;&lt;div&gt;offset&lt;/div&gt;" style="whiteSpace=wrap;html=1;aspect=fixed;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontStyle=1" parent="1" vertex="1">
<mxGeometry x="-108" y="225" width="61" height="61" as="geometry" />
</mxCell>
<mxCell id="yebdUftTMpvAP_zZqaQb-84" style="edgeStyle=none;curved=1;rounded=0;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontSize=12;startSize=8;endSize=8;" parent="1" source="yebdUftTMpvAP_zZqaQb-59" target="4hBZCaStK4hO_Ke5i-zd-49" edge="1">
Expand Down Expand Up @@ -129,7 +129,7 @@
<mxCell id="xJucLK9_7ad-ibpwWDO7-15" value="" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=4.048703703703723;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontStyle=1;rotation=90;labelPosition=center;verticalLabelPosition=middle;align=center;verticalAlign=middle;container=0;strokeWidth=1.2;strokeColor=default;textDirection=ltr;" parent="1" vertex="1">
<mxGeometry x="-329" y="353" width="42.46" height="86.93" as="geometry" />
</mxCell>
<mxCell id="xJucLK9_7ad-ibpwWDO7-16" value="Coordinating task queue" style="text;whiteSpace=wrap;html=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;align=center;fontStyle=1" parent="1" vertex="1">
<mxCell id="xJucLK9_7ad-ibpwWDO7-16" value="Orchestrating task queue" style="text;whiteSpace=wrap;html=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;align=center;fontStyle=1" parent="1" vertex="1">
<mxGeometry x="-344" y="378" width="67" height="28" as="geometry" />
</mxCell>
<mxCell id="xJucLK9_7ad-ibpwWDO7-18" value="Canvas metadata redis&amp;nbsp;&lt;span style=&quot;background-color: initial;&quot;&gt;cluster&lt;/span&gt;&lt;div&gt;&lt;font style=&quot;font-size: 12px;&quot;&gt;&lt;span style=&quot;background-color: initial;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: initial;&quot;&gt;replicated&lt;/span&gt;&lt;span style=&quot;background-color: initial;&quot;&gt;)&lt;/span&gt;&lt;/font&gt;&lt;/div&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=15;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontStyle=1" parent="1" vertex="1">
Expand All @@ -140,16 +140,16 @@
<mxPoint x="-70" y="452" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="_QTCWBG1dnTs1W0XPL4S-4" value="" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;rounded=0;strokeColor=#048b04;strokeWidth=1.2;align=center;verticalAlign=middle;fontSize=12;fontColor=#050505;fontStyle=1;fillColor=#0fd20f;size=13;" vertex="1" parent="1">
<mxCell id="_QTCWBG1dnTs1W0XPL4S-4" value="" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;rounded=0;strokeColor=#048b04;strokeWidth=1.2;align=center;verticalAlign=middle;fontSize=12;fontColor=#050505;fontStyle=1;fillColor=#0fd20f;size=13;" parent="1" vertex="1">
<mxGeometry x="-390" y="-20" width="470" height="82" as="geometry" />
</mxCell>
<mxCell id="_QTCWBG1dnTs1W0XPL4S-1" value="Nginx" style="rhombus;whiteSpace=wrap;html=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;rounded=0;strokeColor=none;strokeWidth=2;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fillColor=#0fd20f;fontColor=#050505;" vertex="1" parent="1">
<mxCell id="_QTCWBG1dnTs1W0XPL4S-1" value="Nginx" style="rhombus;whiteSpace=wrap;html=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;rounded=0;strokeColor=none;strokeWidth=2;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fillColor=#0fd20f;fontColor=#050505;" parent="1" vertex="1">
<mxGeometry x="-107" y="-12" width="66" height="66" as="geometry" />
</mxCell>
<mxCell id="_QTCWBG1dnTs1W0XPL4S-6" value="Chunk stream compression coordination service" style="rounded=0;whiteSpace=wrap;html=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fillColor=#6a00ff;strokeColor=#3700CC;align=center;verticalAlign=middle;fontSize=12;fontColor=#000000;fontStyle=1;strokeWidth=1.2;" vertex="1" parent="1">
<mxCell id="_QTCWBG1dnTs1W0XPL4S-6" value="Chunk image refresh orchestrator" style="rounded=0;whiteSpace=wrap;html=1;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fillColor=#6a00ff;strokeColor=#3700CC;align=center;verticalAlign=middle;fontSize=12;fontColor=#000000;fontStyle=1;strokeWidth=1.2;" parent="1" vertex="1">
<mxGeometry x="-525" y="366" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="_QTCWBG1dnTs1W0XPL4S-7" style="edgeStyle=none;curved=1;rounded=0;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontSize=12;startSize=8;endSize=8;" edge="1" parent="1" source="_QTCWBG1dnTs1W0XPL4S-6" target="xJucLK9_7ad-ibpwWDO7-15">
<mxCell id="_QTCWBG1dnTs1W0XPL4S-7" style="edgeStyle=none;curved=1;rounded=0;sketch=1;hachureGap=4;jiggle=2;curveFitting=1;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;entryPerimeter=0;fontFamily=Architects Daughter;fontSource=https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter;fontSize=12;startSize=8;endSize=8;" parent="1" source="_QTCWBG1dnTs1W0XPL4S-6" target="xJucLK9_7ad-ibpwWDO7-15" edge="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
</root>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import asyncio

from pixel_battle.deployment.chunk_image_refresh_orchestrator.di import (
container,
)
from pixel_battle.presentation.distributed_tasks.refresh_chunk_view import (
RefreshChunkViewTask,
)


async def main() -> None:
task = await container.get(RefreshChunkViewTask)

try:
await task.start_pushing()
finally:
await container.close()


if __name__ == "__main__":
asyncio.run(main())
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)


chunk_stream_compression_service_container = make_async_container(
container = make_async_container(
OutOfProcessInfrastructureProvider(),
OutOfProcessInfrastructureAdapterProvider(),
InteractorProvider(),
Expand Down
19 changes: 19 additions & 0 deletions src/pixel_battle/deployment/chunk_image_refresh_script/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import asyncio

from pixel_battle.deployment.chunk_image_refresh_script.di import container
from pixel_battle.presentation.scripts.refresh_chunk_image import (
RefreshChunkImageScript,
)


async def main() -> None:
script = await container.get(RefreshChunkImageScript)

try:
await script()
finally:
await container.close()


if __name__ == "__main__":
asyncio.run(main())
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)


compression_script_container = make_async_container(
container = make_async_container(
OutOfProcessInfrastructureProvider(),
OutOfProcessInfrastructureAdapterProvider(),
InteractorProvider(),
Expand Down
19 changes: 19 additions & 0 deletions src/pixel_battle/deployment/chunk_image_refresh_worker/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import asyncio

from pixel_battle.deployment.chunk_image_refresh_worker.di import container
from pixel_battle.presentation.distributed_tasks.refresh_chunk_view import (
RefreshChunkViewTask,
)


async def main() -> None:
task = await container.get(RefreshChunkViewTask)

try:
await task.start_pulling()
finally:
await container.close()


if __name__ == "__main__":
asyncio.run(main())
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)


chunk_stream_compression_coordination_service_container = make_async_container(
container = make_async_container(
OutOfProcessInfrastructureProvider(),
OutOfProcessInfrastructureAdapterProvider(),
InteractorProvider(),
Expand Down
6 changes: 2 additions & 4 deletions src/pixel_battle/deployment/chunk_reading_service/asgi.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from pixel_battle.deployment.chunk_reading_service.di import (
chunk_reading_service_container,
)
from pixel_battle.deployment.chunk_reading_service.di import container
from pixel_battle.deployment.common.asgi import ASGIApp, LazyASGIApp
from pixel_battle.presentation.web.app import app_from


async def app_factory() -> ASGIApp:
return await app_from(chunk_reading_service_container)
return await app_from(container)


app = LazyASGIApp(factory=app_factory)
2 changes: 1 addition & 1 deletion src/pixel_battle/deployment/chunk_reading_service/di.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def provide_coroutines(self) -> AppCoroutines:
return []


chunk_reading_service_container = make_async_container(
container = make_async_container(
OutOfProcessInfrastructureProvider(),
OutOfProcessInfrastructureAdapterProvider(),
InteractorProvider(),
Expand Down

This file was deleted.

This file was deleted.

6 changes: 2 additions & 4 deletions src/pixel_battle/deployment/chunk_streaming_service/asgi.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from pixel_battle.deployment.chunk_streaming_service.di import (
chunk_streaming_service_container,
)
from pixel_battle.deployment.chunk_streaming_service.di import container
from pixel_battle.deployment.common.asgi import ASGIApp, LazyASGIApp
from pixel_battle.presentation.web.app import app_from


async def app_factory() -> ASGIApp:
return await app_from(chunk_streaming_service_container)
return await app_from(container)


app = LazyASGIApp(factory=app_factory)
2 changes: 1 addition & 1 deletion src/pixel_battle/deployment/chunk_streaming_service/di.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def provide_coroutines(self, streaming: Streaming) -> AppCoroutines:
return [streaming.start()]


chunk_streaming_service_container = make_async_container(
container = make_async_container(
OutOfProcessInfrastructureProvider(),
OutOfProcessInfrastructureAdapterProvider(),
InteractorProvider(),
Expand Down
6 changes: 2 additions & 4 deletions src/pixel_battle/deployment/chunk_writing_service/asgi.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from pixel_battle.deployment.chunk_writing_service.di import (
chunk_writing_service_container,
)
from pixel_battle.deployment.chunk_writing_service.di import container
from pixel_battle.deployment.common.asgi import ASGIApp, LazyASGIApp
from pixel_battle.presentation.web.app import app_from


async def app_factory() -> ASGIApp:
return await app_from(chunk_writing_service_container)
return await app_from(container)


app = LazyASGIApp(factory=app_factory)
2 changes: 1 addition & 1 deletion src/pixel_battle/deployment/chunk_writing_service/di.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def provide_coroutines(self) -> AppCoroutines:
return []


chunk_writing_service_container = make_async_container(
container = make_async_container(
OutOfProcessInfrastructureProvider(),
OutOfProcessInfrastructureAdapterProvider(),
InteractorProvider(),
Expand Down
Loading

0 comments on commit 05db018

Please sign in to comment.