1use gosh_core::*;
7use gut::prelude::*;
8
9use std::path::{Path, PathBuf};
10mod base;
14mod client;
15mod rest;
16mod scheduler;
17mod server;
18mod worker;
19
20pub mod cli;
21pub mod task;
22
23mod jobhub;
25mod common {
29 pub use gosh_core::gut::prelude::*;
30 pub use gosh_core::*;
31}
32fn hostname() -> String {
37 nix::unistd::gethostname().unwrap().to_str().unwrap().to_string()
38}
39use std::net::{SocketAddr, TcpListener, ToSocketAddrs};
43
44pub fn address_available<A: ToSocketAddrs>(address: A) -> bool {
46 match TcpListener::bind(address) {
47 Ok(_) => true,
48 Err(_) => false,
49 }
50}
51
52pub fn get_free_tcp_address() -> Option<SocketAddr> {
54 let host = hostname();
55 TcpListener::bind(format!("{host}:0")).ok()?.local_addr().ok()
56}
57
58#[test]
59fn test_addr() {
60 let addr = get_free_tcp_address().unwrap();
61 assert!(address_available(dbg!(addr)));
62}
63pub use base::LockFile;
67
68pub use crate::client::Client;
69pub use crate::server::Server;
70pub use jobhub::JobHub;
71#[cfg(feature = "adhoc")]
75pub mod docs {
77 macro_rules! export_doc {
78 ($l:ident) => {
79 pub mod $l {
80 pub use crate::$l::*;
81 }
82 };
83 }
84
85 export_doc!(base);
86 export_doc!(worker);
87 export_doc!(jobhub);
88 export_doc!(rest);
89 export_doc!(task);
90}
91