@@ -76,14 +76,13 @@ This project is still being worked on and is not ready for public release.
7676 sleep(1.0 )
7777 count = count + 1
7878
79- def create_app () -> FastAPI:
80- # connect to postgres and start deepslate
81- platform, _ = new_postgres(1 , DBURL , " localhost:8765" , 100 , 100 , 5 )
82- spawn_fn, _, _, _ = spawn_workers(4 , platform, [counter()])
83- spawn_inspector(platform, " localhost:8080" )
8479
80+ def create_app (spawn_fn , get_fn , trace_fn , shutdown_fn ) -> FastAPI:
8581 app = FastAPI()
8682 app.state.spawn = spawn_fn
83+ app.state.get = get_fn
84+ app.state.trace = trace_fn
85+ app.state.shutdown = shutdown_fn
8786
8887 # spawn a new durable counter flow with the given name
8988 @app.post (" /counter/{name} " )
@@ -94,10 +93,14 @@ This project is still being worked on and is not ready for public release.
9493 return app
9594
9695
97- app = create_app()
98-
99-
10096 if __name__ == " __main__" :
97+ # connect to postgres and start deepslate
98+ platform, _ = new_postgres(1 , DBURL , " localhost:8765" , 100 , 100 , 5 )
99+ spawn_fn, get_fn, trace_fn, shutdown_fn = spawn_workers(4 , platform, [counter()])
100+ spawn_inspector(platform, " localhost:8080" )
101+
102+ # start the server
103+ app = create_app(spawn_fn, get_fn, trace_fn, shutdown_fn)
101104 uvicorn.run(app, host = " 0.0.0.0" , port = 8000 , workers = 1 )
102105 ```
103106
0 commit comments