-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
27 lines (22 loc) · 855 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from datetime import timedelta
from dapr.actor import ActorRuntime
from dapr.actor.runtime.config import ActorRuntimeConfig, ActorReentrancyConfig
from dapr.ext.fastapi import DaprActor # type: ignore
from fastapi import FastAPI # type: ignore
from assemble.actor import TrajectoryAssemblerActor
ActorRuntime.set_actor_config(
ActorRuntimeConfig(
actor_idle_timeout=timedelta(hours=30),
actor_scan_interval=timedelta(hours=1),
drain_ongoing_call_timeout=timedelta(minutes=2),
drain_rebalanced_actors=True,
reentrancy=ActorReentrancyConfig(enabled=False),
)
)
app = FastAPI(title=f'{TrajectoryAssemblerActor.__name__}Service')
# Add Dapr Actor Extension
actor = DaprActor(app)
@app.on_event("startup")
async def startup_event():
# Register
await actor.register_actor(TrajectoryAssemblerActor)