Handshake
parent: tbd commit: e3e5bf5
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 | ; |
61 | |
62 | let token_granter = new |
63 | config: config.clone, |
64 | ; |
65 | |
66 | let user_backend: = new |
67 | db_pool, |
68 | & from_str .unwrap, |
69 | token_granter.clone, |
70 | ; |
71 | |
72 | let discovery_backend: = |
73 | ; | new
74 | |
75 | info!; |
76 | |
77 | loop |
78 | let stream = accept_stream .await; |
79 | info!; |
80 | |
81 | let = match stream |
82 | Ok => stream, |
83 | Err => |
84 | error!; |
85 | continue; |
86 | |
87 | ; |
88 | |
89 | info!; |
90 | |
91 | let connection = accept_websocket_connection .await; |
92 | |
93 | let connection = match connection |
94 | Ok => connection, |
95 | Err => |
96 | error! |
97 | "Failed to initiate Websocket connection from {}. {:?}", |
98 | address, err |
99 | ; |
100 | continue; |
101 | |
102 | ; |
103 | |
104 | info!; |
105 | |
106 | let connection = RawConnection |
107 | task: spawn |
108 | connection, |
109 | listeners.clone, |
110 | connections.clone, |
111 | repository_backend.clone, |
112 | user_backend.clone, |
113 | token_granter.clone, |
114 | discovery_backend.clone, |
115 | address, |
116 | , |
117 | ; |
118 | |
119 | connections.lock .await.connections.push; |
120 | |
121 | |
122 | |
123 | async |
124 | let stream = listener.accept .await?; |
125 | |
126 | Ok |
127 | |
128 | |
129 | async |
130 | stream: S, |
131 | |
132 | let connection = accept_async .await?; |
133 | |
134 | Ok |
135 | |
136 |