Skip to content

Commit

Permalink
feat: #103 show number of routes before loading workers
Browse files Browse the repository at this point in the history
```
$$ target/debug/wws . --ignore 'src/**/*' --ignore 'target/**/*' --ignore 'docs/**/*' --ignore 'crates/**/*' | ts

May 26 08:49:33 ⚙️  Loading routes from: .
May 26 08:49:35 ⏳ Loading workers from 14 routes...
May 26 08:50:13 ✅ Workers loaded in 38.128146575s.
...
```
  • Loading branch information
assambar committed May 26, 2023
1 parent ecc42af commit 6e1c192
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 11 additions & 2 deletions crates/router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ mod route;

use files::Files;
use route::{Route, RouteAffinity};
use std::path::Path;
use std::path::{Path, PathBuf};
use std::time::{Instant};
use wws_config::Config;

/// Contains all registered routes
Expand All @@ -36,10 +37,18 @@ impl Routes {

let files = Files::new(path, runtime_extensions, ignore_patterns);

let mut route_paths: Vec<PathBuf> = Vec::new();
for entry in files.walk() {
routes.push(Route::new(path, entry.into_path(), &prefix, config));
route_paths.push(entry.into_path());
}

println!("⏳ Loading workers from {} routes...", route_paths.len());
let start = Instant::now();
for route_path in route_paths {
routes.push(Route::new(path, route_path, &prefix, config));
}
println!("✅ Workers loaded in {:?}.", start.elapsed());

Self { routes, prefix }
}

Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ async fn main() -> std::io::Result<()> {

println!("⚙️ Loading routes from: {}", &args.path.display());
let routes = Routes::new(&args.path, &args.prefix, args.ignore, &config);

println!("🗺 Detected {} routes:", routes.routes.len());
for route in routes.routes.iter() {
println!(
" - http://{}:{}{}\n => {}",
Expand Down

0 comments on commit 6e1c192

Please sign in to comment.