Add all the user request handling
parent: tbd commit: e3bda14
1 | use Error; |
2 | use ; |
3 | use |
4 | , | AuthenticationTokenGranter
5 | |
6 | , GitBackend, UserAuth, DiscoveryBackend, | GiteratedDiscoveryProtocol
7 | RepositoryBackend, UserBackend, |
8 | , |
9 | connection, listener, |
10 | , | Instance
11 | ; |
12 | use Listeners; |
13 | use ; |
14 | use ; |
15 | use |
16 | , | File
17 | , |
18 | , |
19 | , | Mutex
20 | ; |
21 | use ; |
22 | use Table; |
23 | |
24 | |
25 | extern crate tracing; |
26 | |
27 | |
28 | async |
29 | ; | init
30 | let mut listener = bind .await?; |
31 | let connections: = default; |
32 | let listeners: = default; |
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 db_conn_options = new |
40 | .host |
41 | .port |
42 | .database |
43 | .username |
44 | .password |
45 | .log_statements; |
46 | let db_pool = connect_with .await?; |
47 | |
48 | debug!; |
49 | ! .run .await?; | migrate
50 | info!; |
51 | |
52 | let repository_backend: = |
53 | new |
54 | pg_pool: db_pool.clone, |
55 | repository_folder: String from |
56 | config |
57 | .as_str |
58 | .unwrap, |
59 | , |
60 | instance: from_str .unwrap, |
61 | ; |
62 | |
63 | let token_granter = new |
64 | config: config.clone, |
65 | ; |
66 | |
67 | let user_backend: = new |
68 | db_pool.clone, |
69 | & from_str .unwrap, |
70 | token_granter.clone, |
71 | ; |
72 | |
73 | let discovery_backend: = |
74 | new |
75 | pool: db_pool.clone, |
76 | ; |
77 | |
78 | info!; |
79 | |
80 | loop |
81 | let stream = accept_stream .await; |
82 | info!; |
83 | |
84 | let = match stream |
85 | Ok => stream, |
86 | Err => |
87 | error!; |
88 | continue; |
89 | |
90 | ; |
91 | |
92 | info!; |
93 | |
94 | let connection = accept_websocket_connection .await; |
95 | |
96 | let connection = match connection |
97 | Ok => connection, |
98 | Err => |
99 | error! |
100 | "Failed to initiate Websocket connection from {}. {:?}", |
101 | address, err |
102 | ; |
103 | continue; |
104 | |
105 | ; |
106 | |
107 | info!; |
108 | |
109 | let connection = RawConnection |
110 | task: spawn |
111 | connection, |
112 | listeners.clone, |
113 | connections.clone, |
114 | repository_backend.clone, |
115 | user_backend.clone, |
116 | token_granter.clone, |
117 | discovery_backend.clone, |
118 | address, |
119 | , |
120 | ; |
121 | |
122 | connections.lock .await.connections.push; |
123 | |
124 | |
125 | |
126 | async |
127 | let stream = listener.accept .await?; |
128 | |
129 | Ok |
130 | |
131 | |
132 | async |
133 | stream: S, |
134 | |
135 | let connection = accept_async .await?; |
136 | |
137 | Ok |
138 | |
139 |