The long awaited, exhalted huge networking stack change.
parent: tbd commit: 21b6a72
1 | use Error; |
2 | use CacheSubstack; |
3 | use |
4 | , | AuthenticationTokenGranter
5 | |
6 | , DatabaseSettings, UserAuth, RepositoryBackend, UserBackend, | GitBackend
7 | , |
8 | , | client_wrapper
9 | , | DatabaseBackend
10 | ; |
11 | |
12 | use Instance; |
13 | |
14 | use NetworkedSubstack; |
15 | use GiteratedStackBuilder; |
16 | use ; |
17 | use ; |
18 | use |
19 | , | File
20 | , |
21 | , |
22 | , |
23 | ; |
24 | use ; |
25 | use LocalPoolHandle; |
26 | use Table; |
27 | |
28 | |
29 | extern crate tracing; |
30 | |
31 | |
32 | async |
33 | ; | init
34 | let config: Table = |
35 | let mut file = open .await?; |
36 | let mut text = String new; |
37 | file.read_to_string .await?; |
38 | text.parse? |
39 | ; |
40 | let mut listener = bind .await?; |
41 | let db_conn_options = new |
42 | .host |
43 | .port |
44 | .database |
45 | .username |
46 | .password |
47 | .log_statements; |
48 | let db_pool = connect_with .await?; |
49 | |
50 | debug!; |
51 | ! .run .await?; | migrate
52 | info!; |
53 | |
54 | let stack_cell = new; |
55 | |
56 | let settings = new |
57 | pg_pool: db_pool.clone, |
58 | stack: stack_cell.clone, |
59 | ; |
60 | |
61 | let repository_backend: = |
62 | new |
63 | pg_pool: db_pool.clone, |
64 | repository_folder: String from |
65 | config |
66 | .as_str |
67 | .unwrap, |
68 | , |
69 | instance: from_str |
70 | .unwrap, |
71 | stack: stack_cell.clone, |
72 | ; |
73 | |
74 | let token_granter = new |
75 | config: config.clone, |
76 | instance: from_str .unwrap, |
77 | ; |
78 | |
79 | let user_backend: = new |
80 | db_pool.clone, |
81 | & from_str .unwrap, |
82 | token_granter.clone, |
83 | settings.clone, |
84 | ; |
85 | |
86 | info!; |
87 | |
88 | let database_backend = new |
89 | unwrap, | from_str .
90 | user_backend.clone, |
91 | repository_backend.clone, |
92 | db_pool.clone, |
93 | stack_cell.clone, |
94 | ; |
95 | |
96 | let mut runtime = default; |
97 | |
98 | let database_backend = database_backend.into_substack; |
99 | runtime.merge_builder; |
100 | |
101 | let cache_backend = default; |
102 | runtime.merge_builder; |
103 | |
104 | let networked_stack = NetworkedSubstack |
105 | home_uri: Some |
106 | from_str |
107 | .unwrap |
108 | .0, |
109 | , |
110 | ; |
111 | runtime.merge_builder; |
112 | |
113 | let runtime = runtime.finish; |
114 | |
115 | stack_cell |
116 | .set |
117 | .expect; |
118 | |
119 | let pool = new; |
120 | |
121 | loop |
122 | let stream = accept_stream .await; |
123 | info!; |
124 | |
125 | let = match stream |
126 | Ok => stream, |
127 | Err => |
128 | error!; |
129 | continue; |
130 | |
131 | ; |
132 | |
133 | info!; |
134 | |
135 | let connection = accept_websocket_connection .await; |
136 | |
137 | let connection = match connection |
138 | Ok => connection, |
139 | Err => |
140 | error! |
141 | "Failed to initiate Websocket connection from {}. {:?}", |
142 | address, err |
143 | ; |
144 | continue; |
145 | |
146 | ; |
147 | |
148 | info!; |
149 | |
150 | let our_instance = |
151 | unwrap; | from_str .
152 | let runtime = runtime.clone; |
153 | |
154 | pool.spawn_pinned; |
155 | |
156 | |
157 | |
158 | async |
159 | let stream = listener.accept .await?; |
160 | |
161 | Ok |
162 | |
163 | |
164 | async |
165 | stream: S, |
166 | |
167 | let connection = accept_async .await?; |
168 | |
169 | Ok |
170 | |
171 |