`giterated_cache` initial implementation
# Giterated Stack - Added the ability for dynamic substack handlers to exist for operations relevant to caching. - Added type metadata to the dynamic types. # Giterated Cache - Created - Implemented caching and fetching from cache. Hell fucking yes!!!! It works so good. Are you snooping in the commit logs because you're curious about the history of giterated? Cool that it got so big... tell me I say hi :)
parent: tbd commit: 86afeef
1 | use Error; |
2 | use ; |
3 | use CacheSubstack; |
4 | use |
5 | , | AuthenticationTokenGranter
6 | |
7 | , DatabaseSettings, UserAuth, RepositoryBackend, UserBackend, | GitBackend
8 | , |
9 | , |
10 | , | DatabaseBackend
11 | , | InstanceConnections
12 | ; |
13 | |
14 | use Instance; |
15 | |
16 | use ; |
17 | use ; |
18 | use ; |
19 | use |
20 | , | File
21 | , |
22 | , |
23 | , |
24 | ; |
25 | use ; |
26 | use LocalPoolHandle; |
27 | use Table; |
28 | |
29 | |
30 | extern crate tracing; |
31 | |
32 | |
33 | async |
34 | ; | init
35 | let config: Table = |
36 | let mut file = open .await?; |
37 | let mut text = String new; |
38 | file.read_to_string .await?; |
39 | text.parse? |
40 | ; |
41 | let mut listener = bind .await?; |
42 | let connections: = default; |
43 | let instance_connections: = default; |
44 | let db_conn_options = new |
45 | .host |
46 | .port |
47 | .database |
48 | .username |
49 | .password |
50 | .log_statements; |
51 | let db_pool = connect_with .await?; |
52 | |
53 | debug!; |
54 | ! .run .await?; | migrate
55 | info!; |
56 | |
57 | let stack_cell = new; |
58 | |
59 | let settings = new |
60 | pg_pool: db_pool.clone, |
61 | stack: stack_cell.clone, |
62 | ; |
63 | |
64 | let repository_backend: = |
65 | new |
66 | pg_pool: db_pool.clone, |
67 | repository_folder: String from |
68 | config |
69 | .as_str |
70 | .unwrap, |
71 | , |
72 | instance: from_str |
73 | .unwrap, |
74 | stack: stack_cell.clone, |
75 | ; |
76 | |
77 | let token_granter = new |
78 | config: config.clone, |
79 | instance: from_str .unwrap, |
80 | ; |
81 | |
82 | let user_backend: = new |
83 | db_pool.clone, |
84 | & from_str .unwrap, |
85 | token_granter.clone, |
86 | settings.clone, |
87 | ; |
88 | |
89 | info!; |
90 | |
91 | let database_backend = new |
92 | unwrap, | from_str .
93 | user_backend.clone, |
94 | repository_backend.clone, |
95 | db_pool.clone, |
96 | stack_cell.clone, |
97 | ; |
98 | |
99 | let mut runtime = default; |
100 | |
101 | let database_backend = database_backend.into_substack; |
102 | runtime.merge_builder; |
103 | |
104 | let cache_backend = default; |
105 | runtime.merge_builder; |
106 | |
107 | let runtime = new; |
108 | |
109 | stack_cell |
110 | .set |
111 | .expect; |
112 | |
113 | let operation_state = |
114 | StackOperationState |
115 | our_instance: from_str |
116 | .unwrap, |
117 | runtime: runtime.clone, |
118 | instance: None, |
119 | user: None, |
120 | |
121 | ; |
122 | |
123 | let pool = new; |
124 | |
125 | loop |
126 | let stream = accept_stream .await; |
127 | info!; |
128 | |
129 | let = match stream |
130 | Ok => stream, |
131 | Err => |
132 | error!; |
133 | continue; |
134 | |
135 | ; |
136 | |
137 | info!; |
138 | |
139 | let connection = accept_websocket_connection .await; |
140 | |
141 | let connection = match connection |
142 | Ok => connection, |
143 | Err => |
144 | error! |
145 | "Failed to initiate Websocket connection from {}. {:?}", |
146 | address, err |
147 | ; |
148 | continue; |
149 | |
150 | ; |
151 | |
152 | info!; |
153 | let connections_cloned = connections.clone; |
154 | let repository_backend = repository_backend.clone; |
155 | let user_backend = user_backend.clone; |
156 | let token_granter = token_granter.clone; |
157 | let settings = settings.clone; |
158 | let instance_connections = instance_connections.clone; |
159 | let config = config.clone; |
160 | let runtime = runtime.clone; |
161 | let operation_state = operation_state.clone; |
162 | |
163 | pool.spawn_pinned |
164 | connection_wrapper |
165 | connection, |
166 | connections_cloned, |
167 | repository_backend, |
168 | user_backend, |
169 | token_granter, |
170 | settings, |
171 | address, |
172 | unwrap, | from_str .
173 | instance_connections, |
174 | config, |
175 | runtime, |
176 | operation_state, |
177 | |
178 | ; |
179 | |
180 | let connection = RawConnection |
181 | task: spawn, |
182 | ; |
183 | |
184 | connections.lock .await.connections.push; |
185 | |
186 | |
187 | |
188 | async |
189 | let stream = listener.accept .await?; |
190 | |
191 | Ok |
192 | |
193 | |
194 | async |
195 | stream: S, |
196 | |
197 | let connection = accept_async .await?; |
198 | |
199 | Ok |
200 | |
201 |