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