Huge refactor to prep for moving the daemon over to the plugin architecture
parent: tbd commit: 5df753c
1 | use |
2 | , | Display
3 | str FromStr, |
4 | , |
5 | ; |
6 | |
7 | use Error; |
8 | use ; |
9 | use |
10 | , | PluginInitializationState
11 | , |
12 | , |
13 | ; |
14 | use PluginStackBuilder; |
15 | use |
16 | create_issue_request, edit_issue_request, issue_get_setting_contents, issue_get_setting_name, |
17 | issue_post_comment_request, issue_set_setting_contents, issue_set_setting_name, |
18 | issue_value_author, issue_value_comment_count, issue_value_creation_date, query_issues_request, |
19 | ; |
20 | use ; |
21 | use ; |
22 | use ; |
23 | use |
24 | , | File
25 | , | AsyncReadExt
26 | , | Runtime
27 | spawn, |
28 | , |
29 | ; |
30 | use Table; |
31 | use ; |
32 | use ; |
33 | |
34 | |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | /// An issue, defined by the repository which owns it and its index. |
41 | /// |
42 | /// # Textual Format |
43 | /// An issue's textual format is defined as: |
44 | /// |
45 | /// `@{index: u32}:{repository: Repository}` |
46 | |
47 | |
48 | pub repository: Repository, |
49 | pub id: u32, |
50 | |
51 | |
52 | |
53 | |
54 | f.write_str |
55 | |
56 | |
57 | |
58 | |
59 | |
60 | "issue" |
61 | |
62 | |
63 | |
64 | self.repository.home_uri |
65 | |
66 | |
67 | |
68 | Ok |
69 | |
70 | |
71 | |
72 | |
73 | type Err = IssueParseError; |
74 | |
75 | |
76 | let = s.split_once .ok_or_else?; |
77 | |
78 | let id: u32 = index.parse .map_err?; |
79 | let repository = from_str .map_err?; |
80 | |
81 | Ok |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | ; |
88 | |
89 | static INIT_VTABLE: = new; |
90 | static ASYNC_RUNTIME: = new; |
91 | |
92 | |
93 | pub extern "C" |
94 | const PLUGIN_NAME: &str = "Giterated [Issues]"; |
95 | const PLUGIN_VERSION: &str = "0.1.0"; |
96 | |
97 | FFIPluginMeta |
98 | name: PLUGIN_NAME.as_ptr, |
99 | name_len: PLUGIN_NAME.len, |
100 | version: PLUGIN_VERSION.as_ptr, |
101 | version_len: PLUGIN_VERSION.len, |
102 | |
103 | |
104 | |
105 | |
106 | pub extern "C" |
107 | println!; |
108 | |
109 | |
110 | |
111 | pub extern "C" |
112 | INIT_VTABLE.set .unwrap; |
113 | println!; |
114 | |
115 | |
116 | |
117 | pub extern "C" |
118 | // tracing_subscriber::fmt() |
119 | // .pretty() |
120 | // .with_thread_names(true) |
121 | // .with_max_level(Level::TRACE) |
122 | // .init(); |
123 | |
124 | PluginState |
125 | inner: Box into_raw, |
126 | |
127 | |
128 | |
129 | |
130 | pub extern "C" |
131 | state: *mut PluginInitializationState, |
132 | *mut PluginInitializationState |
133 | let runtime = new .unwrap; |
134 | |
135 | // let _guard: tracing::span::EnteredSpan = trace_span!("initialize_registration").entered(); |
136 | let init_vtable = INIT_VTABLE.get .unwrap; |
137 | |
138 | let db_pool = runtime.block_on |
139 | let config: Table = |
140 | let mut file = open .await.unwrap; |
141 | let mut text = String new; |
142 | file.read_to_string .await.unwrap; |
143 | text.parse .unwrap |
144 | ; |
145 | let db_conn_options = new |
146 | .host |
147 | .port |
148 | .database |
149 | .username |
150 | .password; |
151 | let db_pool = connect_with .await.unwrap; |
152 | |
153 | debug!; |
154 | // sqlx::migrate!().run(&db_pool).await.unwrap(); |
155 | info!; |
156 | |
157 | db_pool |
158 | ; |
159 | |
160 | ASYNC_RUNTIME.set .unwrap; |
161 | |
162 | let plugin_state = IssuesPluginState ; |
163 | |
164 | let mut builder: = |
165 | ; | new
166 | |
167 | builder.; |
168 | |
169 | builder |
170 | .object_setting |
171 | .object_setting; |
172 | |
173 | builder.; |
174 | |
175 | builder |
176 | .value |
177 | .value |
178 | .value |
179 | .value; |
180 | |
181 | builder |
182 | .operation |
183 | .operation |
184 | .operation |
185 | .operation; |
186 | |
187 | state |
188 | |
189 | |
190 | |
191 | |
192 | pub pool: PgPool, |
193 | |
194 |