| 112 | } |
| 113 | |
| 114 | fn setup_watcher<F>(mut callback: F) -> notify::Result<RecommendedWatcher> |
| 115 | where |
| 116 | F: FnMut(notify::Event) + Send + 'static, |
| 117 | { |
| 118 | let watcher = notify::recommended_watcher(move |res: notify::Result<notify::Event>| { |
| 119 | match res { |
| 120 | Ok(event) => { |
| 121 | // Only trigger on write/create/remove events |
| 122 | if event.kind.is_modify() || event.kind.is_create() || event.kind.is_remove() { |
| 123 | callback(event); |
| 124 | } |
| 125 | } |
| 126 | Err(e) => println!("Watch error: {:?}", e), |
| 127 | } |
| 128 | })?; |
| 129 | Ok(watcher) |
| 130 | } |
| 131 | |
| 132 | pub async fn get_pg_connection() -> Option<PgPool> { |
| 133 | let config = Config::get(); |