Fixes
parent: tbd commit: 73a5af5
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 | , | File
19 | , |
20 | , |
21 | , | Mutex
22 | ; |
23 | use ; |
24 | use Table; |
25 | |
26 | |
27 | extern crate tracing; |
28 | |
29 | |
30 | async |
31 | ; | init
32 | let config: Table = |
33 | let mut file = open .await?; |
34 | let mut text = String new; |
35 | file.read_to_string .await?; |
36 | text.parse? |
37 | ; |
38 | let mut listener = bind .await?; |
39 | let connections: = default; |
40 | let instance_connections: = default; |
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 settings = new |
55 | pg_pool: db_pool.clone, |
56 | ; |
57 | |
58 | let repository_backend: = |
59 | new |
60 | pg_pool: db_pool.clone, |
61 | repository_folder: String from |
62 | config |
63 | .as_str |
64 | .unwrap, |
65 | , |
66 | instance: from_str |
67 | .unwrap, |
68 | settings_provider: settings.clone, |
69 | ; |
70 | |
71 | let token_granter = new |
72 | config: config.clone, |
73 | instance: from_str .unwrap, |
74 | ; |
75 | |
76 | let user_backend: = new |
77 | db_pool.clone, |
78 | & from_str .unwrap, |
79 | token_granter.clone, |
80 | settings.clone, |
81 | ; |
82 | |
83 | info!; |
84 | |
85 | let database_backend = new |
86 | unwrap, | from_str .
87 | user_backend.clone, |
88 | repository_backend.clone, |
89 | ; |
90 | |
91 | loop |
92 | let stream = accept_stream .await; |
93 | info!; |
94 | |
95 | let = match stream |
96 | Ok => stream, |
97 | Err => |
98 | error!; |
99 | continue; |
100 | |
101 | ; |
102 | |
103 | info!; |
104 | |
105 | let connection = accept_websocket_connection .await; |
106 | |
107 | let connection = match connection |
108 | Ok => connection, |
109 | Err => |
110 | error! |
111 | "Failed to initiate Websocket connection from {}. {:?}", |
112 | address, err |
113 | ; |
114 | continue; |
115 | |
116 | ; |
117 | |
118 | info!; |
119 | |
120 | let connection = RawConnection |
121 | task: spawn |
122 | connection, |
123 | connections.clone, |
124 | repository_backend.clone, |
125 | user_backend.clone, |
126 | token_granter.clone, |
127 | settings.clone, |
128 | address, |
129 | unwrap, | from_str .
130 | instance_connections.clone, |
131 | config.clone, |
132 | database_backend.clone, |
133 | , |
134 | ; |
135 | |
136 | connections.lock .await.connections.push; |
137 | |
138 | |
139 | |
140 | async |
141 | let stream = listener.accept .await?; |
142 | |
143 | Ok |
144 | |
145 | |
146 | async |
147 | stream: S, |
148 | |
149 | let connection = accept_async .await?; |
150 | |
151 | Ok |
152 | |
153 |