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