Create `NetworkedSubstack`.
# giterated-protocol - Create `NetworkedSubstack` which will handle all networked operations giterated needs - Add support for `NetworkedSubstack` for both the daemon and client - Pipe everything through but leave APIs temp # `giterated-daemon` - Remove a bunch of random old code, dead code, and files that aren't needed. - Moved all connection handling to `client.rs`, simplified connection logic with new types
parent: tbd commit: 202bb12
1 | use Error; |
2 | use CacheSubstack; |
3 | use |
4 | , | AuthenticationTokenGranter
5 | |
6 | , DatabaseSettings, UserAuth, RepositoryBackend, UserBackend, | GitBackend
7 | , |
8 | , | client_wrapper
9 | , | DatabaseBackend
10 | ; |
11 | |
12 | use Instance; |
13 | |
14 | use GiteratedStack; |
15 | use ; |
16 | use ; |
17 | use |
18 | , | File
19 | , |
20 | , |
21 | , |
22 | ; |
23 | use ; |
24 | use LocalPoolHandle; |
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 db_conn_options = new |
41 | .host |
42 | .port |
43 | .database |
44 | .username |
45 | .password |
46 | .log_statements; |
47 | let db_pool = connect_with .await?; |
48 | |
49 | debug!; |
50 | ! .run .await?; | migrate
51 | info!; |
52 | |
53 | let stack_cell = new; |
54 | |
55 | let settings = new |
56 | pg_pool: db_pool.clone, |
57 | stack: stack_cell.clone, |
58 | ; |
59 | |
60 | let repository_backend: = |
61 | new |
62 | pg_pool: db_pool.clone, |
63 | repository_folder: String from |
64 | config |
65 | .as_str |
66 | .unwrap, |
67 | , |
68 | instance: from_str |
69 | .unwrap, |
70 | stack: stack_cell.clone, |
71 | ; |
72 | |
73 | let token_granter = new |
74 | config: config.clone, |
75 | instance: from_str .unwrap, |
76 | ; |
77 | |
78 | let user_backend: = new |
79 | db_pool.clone, |
80 | & from_str .unwrap, |
81 | token_granter.clone, |
82 | settings.clone, |
83 | ; |
84 | |
85 | info!; |
86 | |
87 | let database_backend = new |
88 | unwrap, | from_str .
89 | user_backend.clone, |
90 | repository_backend.clone, |
91 | db_pool.clone, |
92 | stack_cell.clone, |
93 | ; |
94 | |
95 | let mut runtime = default; |
96 | |
97 | let database_backend = database_backend.into_substack; |
98 | runtime.merge_builder; |
99 | |
100 | let cache_backend = default; |
101 | runtime.merge_builder; |
102 | |
103 | let runtime = new; |
104 | |
105 | stack_cell |
106 | .set |
107 | .expect; |
108 | |
109 | let pool = new; |
110 | |
111 | loop |
112 | let stream = accept_stream .await; |
113 | info!; |
114 | |
115 | let = match stream |
116 | Ok => stream, |
117 | Err => |
118 | error!; |
119 | continue; |
120 | |
121 | ; |
122 | |
123 | info!; |
124 | |
125 | let connection = accept_websocket_connection .await; |
126 | |
127 | let connection = match connection |
128 | Ok => connection, |
129 | Err => |
130 | error! |
131 | "Failed to initiate Websocket connection from {}. {:?}", |
132 | address, err |
133 | ; |
134 | continue; |
135 | |
136 | ; |
137 | |
138 | info!; |
139 | |
140 | let our_instance = |
141 | unwrap; | from_str .
142 | let runtime = runtime.clone; |
143 | |
144 | pool.spawn_pinned; |
145 | |
146 | |
147 | |
148 | async |
149 | let stream = listener.accept .await?; |
150 | |
151 | Ok |
152 | |
153 | |
154 | async |
155 | stream: S, |
156 | |
157 | let connection = accept_async .await?; |
158 | |
159 | Ok |
160 | |
161 |