|
1 | 1 | use std::{ |
2 | | - collections::hash_map::DefaultHasher, |
| 2 | + collections::{hash_map::DefaultHasher, HashSet}, |
3 | 3 | env, |
4 | 4 | hash::{Hash, Hasher}, |
5 | 5 | }; |
@@ -137,28 +137,24 @@ impl SpinEngine { |
137 | 137 | configure_application_variables_from_environment_variables(&locked_app)?; |
138 | 138 | let trigger_cmds = get_supported_triggers(&locked_app) |
139 | 139 | .with_context(|| format!("Couldn't find trigger executor for {app_source:?}"))?; |
140 | | - |
141 | 140 | let _telemetry_guard = spin_telemetry::init(version!().to_string())?; |
142 | 141 |
|
143 | | - self.run_trigger( |
144 | | - ctx, |
145 | | - trigger_cmds.iter().map(|s| s.as_ref()).collect(), |
146 | | - locked_app, |
147 | | - app_source, |
148 | | - ) |
149 | | - .await |
| 142 | + self.run_trigger(ctx, &trigger_cmds, locked_app, app_source) |
| 143 | + .await |
150 | 144 | } |
151 | 145 |
|
152 | 146 | async fn run_trigger( |
153 | 147 | &self, |
154 | 148 | ctx: &impl RuntimeContext, |
155 | | - trigger_types: Vec<&str>, |
| 149 | + trigger_types: &HashSet<String>, |
156 | 150 | app: LockedApp, |
157 | 151 | app_source: Source, |
158 | 152 | ) -> Result<()> { |
159 | | - let mut futures_list = Vec::with_capacity(trigger_types.len()); |
| 153 | + let mut futures_list = Vec::new(); |
| 154 | + let mut trigger_type_map = Vec::new(); |
| 155 | + |
160 | 156 | for trigger_type in trigger_types.iter() { |
161 | | - let f = match trigger_type.to_owned() { |
| 157 | + let f = match trigger_type.as_str() { |
162 | 158 | HttpTrigger::TRIGGER_TYPE => { |
163 | 159 | let http_trigger = |
164 | 160 | build_trigger::<HttpTrigger>(app.clone(), app_source.clone()).await?; |
@@ -204,17 +200,17 @@ impl SpinEngine { |
204 | 200 | } |
205 | 201 | }; |
206 | 202 |
|
207 | | - futures_list.push(f) |
| 203 | + trigger_type_map.push(trigger_type.clone()); |
| 204 | + futures_list.push(f); |
208 | 205 | } |
209 | 206 |
|
210 | 207 | info!(" >>> notifying main thread we are about to start"); |
211 | 208 |
|
212 | 209 | // exit as soon as any of the trigger completes/exits |
213 | 210 | let (result, index, rest) = future::select_all(futures_list).await; |
214 | | - info!( |
215 | | - " >>> trigger type '{trigger_type}' exited", |
216 | | - trigger_type = trigger_types[index] |
217 | | - ); |
| 211 | + let trigger_type = &trigger_type_map[index]; |
| 212 | + |
| 213 | + info!(" >>> trigger type '{trigger_type}' exited"); |
218 | 214 |
|
219 | 215 | drop(rest); |
220 | 216 |
|
|
0 commit comments