pub struct ControlClient { /* private fields */ }Implementations§
Source§impl ControlClient
impl ControlClient
Sourcepub fn builder(socket: impl Into<String>) -> ControlClientBuilder
pub fn builder(socket: impl Into<String>) -> ControlClientBuilder
Examples found in repository?
examples/control.rs (line 14)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut args = env::args().skip(1);
7 let action = args.next().unwrap_or_else(|| "status".to_string());
8
9 let socket =
10 env::var("FALCORN_CONTROL_SOCKET").unwrap_or_else(|_| DEFAULT_CONTROL_SOCKET.to_string());
11 let token = env::var("FALCORN_CONTROL_TOKEN").ok();
12 let client_name = env::var("FALCORN_CONTROL_CLIENT").ok();
13
14 let mut builder = ControlClient::builder(socket);
15 if let Some(token) = token {
16 builder = builder.auth_token(token);
17 }
18 if let Some(client_name) = client_name {
19 builder = builder.client_name(client_name);
20 }
21
22 let mut client = builder.connect()?;
23
24 match action.as_str() {
25 "status" => {
26 let status = client.get_status()?;
27 println!("{:#?}", status);
28 }
29 "workers" => {
30 let workers = client.get_workers()?;
31 println!("{:#?}", workers);
32 }
33 "show-config" => {
34 let config = client.show_config()?;
35 println!("{}", config);
36 }
37 "scale" => {
38 let workers = args
39 .next()
40 .ok_or("scale requires worker count")?
41 .parse::<usize>()?;
42 let message = client.scale_to(workers)?;
43 println!("{}", message);
44 }
45 "restart" => {
46 let id = args.next().and_then(|value| value.parse::<u32>().ok());
47 let force = args.any(|value| value == "--force");
48 let message = client.restart_worker(id, !force)?;
49 println!("{}", message);
50 }
51 "shutdown" => {
52 let force = args.any(|value| value == "--force");
53 let message = client.shutdown(!force)?;
54 println!("{}", message);
55 }
56 "reload" => {
57 let mut path = None;
58 let mut rolling = true;
59 for value in args {
60 if value == "--no-rolling" {
61 rolling = false;
62 } else if value.starts_with("--path=") {
63 path = value.split('=').nth(1).map(|s| s.to_string());
64 } else if path.is_none() {
65 path = Some(value);
66 }
67 }
68 let message = client.reload_config(path, rolling)?;
69 println!("{}", message);
70 }
71 other => {
72 eprintln!(
73 "Unknown action: {} (use status|workers|show-config|scale|restart|shutdown|reload)",
74 other
75 );
76 }
77 }
78
79 Ok(())
80}pub fn send_action( &mut self, action: ActionKind, payload: Option<ActionRequestPayload>, ) -> Result<ActionResponse>
Sourcepub fn get_status(&mut self) -> Result<StatusSnapshot>
pub fn get_status(&mut self) -> Result<StatusSnapshot>
Examples found in repository?
examples/control.rs (line 26)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut args = env::args().skip(1);
7 let action = args.next().unwrap_or_else(|| "status".to_string());
8
9 let socket =
10 env::var("FALCORN_CONTROL_SOCKET").unwrap_or_else(|_| DEFAULT_CONTROL_SOCKET.to_string());
11 let token = env::var("FALCORN_CONTROL_TOKEN").ok();
12 let client_name = env::var("FALCORN_CONTROL_CLIENT").ok();
13
14 let mut builder = ControlClient::builder(socket);
15 if let Some(token) = token {
16 builder = builder.auth_token(token);
17 }
18 if let Some(client_name) = client_name {
19 builder = builder.client_name(client_name);
20 }
21
22 let mut client = builder.connect()?;
23
24 match action.as_str() {
25 "status" => {
26 let status = client.get_status()?;
27 println!("{:#?}", status);
28 }
29 "workers" => {
30 let workers = client.get_workers()?;
31 println!("{:#?}", workers);
32 }
33 "show-config" => {
34 let config = client.show_config()?;
35 println!("{}", config);
36 }
37 "scale" => {
38 let workers = args
39 .next()
40 .ok_or("scale requires worker count")?
41 .parse::<usize>()?;
42 let message = client.scale_to(workers)?;
43 println!("{}", message);
44 }
45 "restart" => {
46 let id = args.next().and_then(|value| value.parse::<u32>().ok());
47 let force = args.any(|value| value == "--force");
48 let message = client.restart_worker(id, !force)?;
49 println!("{}", message);
50 }
51 "shutdown" => {
52 let force = args.any(|value| value == "--force");
53 let message = client.shutdown(!force)?;
54 println!("{}", message);
55 }
56 "reload" => {
57 let mut path = None;
58 let mut rolling = true;
59 for value in args {
60 if value == "--no-rolling" {
61 rolling = false;
62 } else if value.starts_with("--path=") {
63 path = value.split('=').nth(1).map(|s| s.to_string());
64 } else if path.is_none() {
65 path = Some(value);
66 }
67 }
68 let message = client.reload_config(path, rolling)?;
69 println!("{}", message);
70 }
71 other => {
72 eprintln!(
73 "Unknown action: {} (use status|workers|show-config|scale|restart|shutdown|reload)",
74 other
75 );
76 }
77 }
78
79 Ok(())
80}Sourcepub fn get_workers(&mut self) -> Result<Vec<WorkerSnapshot>>
pub fn get_workers(&mut self) -> Result<Vec<WorkerSnapshot>>
Examples found in repository?
examples/control.rs (line 30)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut args = env::args().skip(1);
7 let action = args.next().unwrap_or_else(|| "status".to_string());
8
9 let socket =
10 env::var("FALCORN_CONTROL_SOCKET").unwrap_or_else(|_| DEFAULT_CONTROL_SOCKET.to_string());
11 let token = env::var("FALCORN_CONTROL_TOKEN").ok();
12 let client_name = env::var("FALCORN_CONTROL_CLIENT").ok();
13
14 let mut builder = ControlClient::builder(socket);
15 if let Some(token) = token {
16 builder = builder.auth_token(token);
17 }
18 if let Some(client_name) = client_name {
19 builder = builder.client_name(client_name);
20 }
21
22 let mut client = builder.connect()?;
23
24 match action.as_str() {
25 "status" => {
26 let status = client.get_status()?;
27 println!("{:#?}", status);
28 }
29 "workers" => {
30 let workers = client.get_workers()?;
31 println!("{:#?}", workers);
32 }
33 "show-config" => {
34 let config = client.show_config()?;
35 println!("{}", config);
36 }
37 "scale" => {
38 let workers = args
39 .next()
40 .ok_or("scale requires worker count")?
41 .parse::<usize>()?;
42 let message = client.scale_to(workers)?;
43 println!("{}", message);
44 }
45 "restart" => {
46 let id = args.next().and_then(|value| value.parse::<u32>().ok());
47 let force = args.any(|value| value == "--force");
48 let message = client.restart_worker(id, !force)?;
49 println!("{}", message);
50 }
51 "shutdown" => {
52 let force = args.any(|value| value == "--force");
53 let message = client.shutdown(!force)?;
54 println!("{}", message);
55 }
56 "reload" => {
57 let mut path = None;
58 let mut rolling = true;
59 for value in args {
60 if value == "--no-rolling" {
61 rolling = false;
62 } else if value.starts_with("--path=") {
63 path = value.split('=').nth(1).map(|s| s.to_string());
64 } else if path.is_none() {
65 path = Some(value);
66 }
67 }
68 let message = client.reload_config(path, rolling)?;
69 println!("{}", message);
70 }
71 other => {
72 eprintln!(
73 "Unknown action: {} (use status|workers|show-config|scale|restart|shutdown|reload)",
74 other
75 );
76 }
77 }
78
79 Ok(())
80}Sourcepub fn show_config(&mut self) -> Result<String>
pub fn show_config(&mut self) -> Result<String>
Examples found in repository?
examples/control.rs (line 34)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut args = env::args().skip(1);
7 let action = args.next().unwrap_or_else(|| "status".to_string());
8
9 let socket =
10 env::var("FALCORN_CONTROL_SOCKET").unwrap_or_else(|_| DEFAULT_CONTROL_SOCKET.to_string());
11 let token = env::var("FALCORN_CONTROL_TOKEN").ok();
12 let client_name = env::var("FALCORN_CONTROL_CLIENT").ok();
13
14 let mut builder = ControlClient::builder(socket);
15 if let Some(token) = token {
16 builder = builder.auth_token(token);
17 }
18 if let Some(client_name) = client_name {
19 builder = builder.client_name(client_name);
20 }
21
22 let mut client = builder.connect()?;
23
24 match action.as_str() {
25 "status" => {
26 let status = client.get_status()?;
27 println!("{:#?}", status);
28 }
29 "workers" => {
30 let workers = client.get_workers()?;
31 println!("{:#?}", workers);
32 }
33 "show-config" => {
34 let config = client.show_config()?;
35 println!("{}", config);
36 }
37 "scale" => {
38 let workers = args
39 .next()
40 .ok_or("scale requires worker count")?
41 .parse::<usize>()?;
42 let message = client.scale_to(workers)?;
43 println!("{}", message);
44 }
45 "restart" => {
46 let id = args.next().and_then(|value| value.parse::<u32>().ok());
47 let force = args.any(|value| value == "--force");
48 let message = client.restart_worker(id, !force)?;
49 println!("{}", message);
50 }
51 "shutdown" => {
52 let force = args.any(|value| value == "--force");
53 let message = client.shutdown(!force)?;
54 println!("{}", message);
55 }
56 "reload" => {
57 let mut path = None;
58 let mut rolling = true;
59 for value in args {
60 if value == "--no-rolling" {
61 rolling = false;
62 } else if value.starts_with("--path=") {
63 path = value.split('=').nth(1).map(|s| s.to_string());
64 } else if path.is_none() {
65 path = Some(value);
66 }
67 }
68 let message = client.reload_config(path, rolling)?;
69 println!("{}", message);
70 }
71 other => {
72 eprintln!(
73 "Unknown action: {} (use status|workers|show-config|scale|restart|shutdown|reload)",
74 other
75 );
76 }
77 }
78
79 Ok(())
80}Sourcepub fn scale_to(&mut self, workers: usize) -> Result<String>
pub fn scale_to(&mut self, workers: usize) -> Result<String>
Examples found in repository?
examples/control.rs (line 42)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut args = env::args().skip(1);
7 let action = args.next().unwrap_or_else(|| "status".to_string());
8
9 let socket =
10 env::var("FALCORN_CONTROL_SOCKET").unwrap_or_else(|_| DEFAULT_CONTROL_SOCKET.to_string());
11 let token = env::var("FALCORN_CONTROL_TOKEN").ok();
12 let client_name = env::var("FALCORN_CONTROL_CLIENT").ok();
13
14 let mut builder = ControlClient::builder(socket);
15 if let Some(token) = token {
16 builder = builder.auth_token(token);
17 }
18 if let Some(client_name) = client_name {
19 builder = builder.client_name(client_name);
20 }
21
22 let mut client = builder.connect()?;
23
24 match action.as_str() {
25 "status" => {
26 let status = client.get_status()?;
27 println!("{:#?}", status);
28 }
29 "workers" => {
30 let workers = client.get_workers()?;
31 println!("{:#?}", workers);
32 }
33 "show-config" => {
34 let config = client.show_config()?;
35 println!("{}", config);
36 }
37 "scale" => {
38 let workers = args
39 .next()
40 .ok_or("scale requires worker count")?
41 .parse::<usize>()?;
42 let message = client.scale_to(workers)?;
43 println!("{}", message);
44 }
45 "restart" => {
46 let id = args.next().and_then(|value| value.parse::<u32>().ok());
47 let force = args.any(|value| value == "--force");
48 let message = client.restart_worker(id, !force)?;
49 println!("{}", message);
50 }
51 "shutdown" => {
52 let force = args.any(|value| value == "--force");
53 let message = client.shutdown(!force)?;
54 println!("{}", message);
55 }
56 "reload" => {
57 let mut path = None;
58 let mut rolling = true;
59 for value in args {
60 if value == "--no-rolling" {
61 rolling = false;
62 } else if value.starts_with("--path=") {
63 path = value.split('=').nth(1).map(|s| s.to_string());
64 } else if path.is_none() {
65 path = Some(value);
66 }
67 }
68 let message = client.reload_config(path, rolling)?;
69 println!("{}", message);
70 }
71 other => {
72 eprintln!(
73 "Unknown action: {} (use status|workers|show-config|scale|restart|shutdown|reload)",
74 other
75 );
76 }
77 }
78
79 Ok(())
80}Sourcepub fn restart_worker(
&mut self,
id: Option<u32>,
graceful: bool,
) -> Result<String>
pub fn restart_worker( &mut self, id: Option<u32>, graceful: bool, ) -> Result<String>
Examples found in repository?
examples/control.rs (line 48)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut args = env::args().skip(1);
7 let action = args.next().unwrap_or_else(|| "status".to_string());
8
9 let socket =
10 env::var("FALCORN_CONTROL_SOCKET").unwrap_or_else(|_| DEFAULT_CONTROL_SOCKET.to_string());
11 let token = env::var("FALCORN_CONTROL_TOKEN").ok();
12 let client_name = env::var("FALCORN_CONTROL_CLIENT").ok();
13
14 let mut builder = ControlClient::builder(socket);
15 if let Some(token) = token {
16 builder = builder.auth_token(token);
17 }
18 if let Some(client_name) = client_name {
19 builder = builder.client_name(client_name);
20 }
21
22 let mut client = builder.connect()?;
23
24 match action.as_str() {
25 "status" => {
26 let status = client.get_status()?;
27 println!("{:#?}", status);
28 }
29 "workers" => {
30 let workers = client.get_workers()?;
31 println!("{:#?}", workers);
32 }
33 "show-config" => {
34 let config = client.show_config()?;
35 println!("{}", config);
36 }
37 "scale" => {
38 let workers = args
39 .next()
40 .ok_or("scale requires worker count")?
41 .parse::<usize>()?;
42 let message = client.scale_to(workers)?;
43 println!("{}", message);
44 }
45 "restart" => {
46 let id = args.next().and_then(|value| value.parse::<u32>().ok());
47 let force = args.any(|value| value == "--force");
48 let message = client.restart_worker(id, !force)?;
49 println!("{}", message);
50 }
51 "shutdown" => {
52 let force = args.any(|value| value == "--force");
53 let message = client.shutdown(!force)?;
54 println!("{}", message);
55 }
56 "reload" => {
57 let mut path = None;
58 let mut rolling = true;
59 for value in args {
60 if value == "--no-rolling" {
61 rolling = false;
62 } else if value.starts_with("--path=") {
63 path = value.split('=').nth(1).map(|s| s.to_string());
64 } else if path.is_none() {
65 path = Some(value);
66 }
67 }
68 let message = client.reload_config(path, rolling)?;
69 println!("{}", message);
70 }
71 other => {
72 eprintln!(
73 "Unknown action: {} (use status|workers|show-config|scale|restart|shutdown|reload)",
74 other
75 );
76 }
77 }
78
79 Ok(())
80}Sourcepub fn shutdown(&mut self, graceful: bool) -> Result<String>
pub fn shutdown(&mut self, graceful: bool) -> Result<String>
Examples found in repository?
examples/control.rs (line 53)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut args = env::args().skip(1);
7 let action = args.next().unwrap_or_else(|| "status".to_string());
8
9 let socket =
10 env::var("FALCORN_CONTROL_SOCKET").unwrap_or_else(|_| DEFAULT_CONTROL_SOCKET.to_string());
11 let token = env::var("FALCORN_CONTROL_TOKEN").ok();
12 let client_name = env::var("FALCORN_CONTROL_CLIENT").ok();
13
14 let mut builder = ControlClient::builder(socket);
15 if let Some(token) = token {
16 builder = builder.auth_token(token);
17 }
18 if let Some(client_name) = client_name {
19 builder = builder.client_name(client_name);
20 }
21
22 let mut client = builder.connect()?;
23
24 match action.as_str() {
25 "status" => {
26 let status = client.get_status()?;
27 println!("{:#?}", status);
28 }
29 "workers" => {
30 let workers = client.get_workers()?;
31 println!("{:#?}", workers);
32 }
33 "show-config" => {
34 let config = client.show_config()?;
35 println!("{}", config);
36 }
37 "scale" => {
38 let workers = args
39 .next()
40 .ok_or("scale requires worker count")?
41 .parse::<usize>()?;
42 let message = client.scale_to(workers)?;
43 println!("{}", message);
44 }
45 "restart" => {
46 let id = args.next().and_then(|value| value.parse::<u32>().ok());
47 let force = args.any(|value| value == "--force");
48 let message = client.restart_worker(id, !force)?;
49 println!("{}", message);
50 }
51 "shutdown" => {
52 let force = args.any(|value| value == "--force");
53 let message = client.shutdown(!force)?;
54 println!("{}", message);
55 }
56 "reload" => {
57 let mut path = None;
58 let mut rolling = true;
59 for value in args {
60 if value == "--no-rolling" {
61 rolling = false;
62 } else if value.starts_with("--path=") {
63 path = value.split('=').nth(1).map(|s| s.to_string());
64 } else if path.is_none() {
65 path = Some(value);
66 }
67 }
68 let message = client.reload_config(path, rolling)?;
69 println!("{}", message);
70 }
71 other => {
72 eprintln!(
73 "Unknown action: {} (use status|workers|show-config|scale|restart|shutdown|reload)",
74 other
75 );
76 }
77 }
78
79 Ok(())
80}Sourcepub fn reload_config(
&mut self,
path: Option<String>,
rolling: bool,
) -> Result<String>
pub fn reload_config( &mut self, path: Option<String>, rolling: bool, ) -> Result<String>
Examples found in repository?
examples/control.rs (line 68)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut args = env::args().skip(1);
7 let action = args.next().unwrap_or_else(|| "status".to_string());
8
9 let socket =
10 env::var("FALCORN_CONTROL_SOCKET").unwrap_or_else(|_| DEFAULT_CONTROL_SOCKET.to_string());
11 let token = env::var("FALCORN_CONTROL_TOKEN").ok();
12 let client_name = env::var("FALCORN_CONTROL_CLIENT").ok();
13
14 let mut builder = ControlClient::builder(socket);
15 if let Some(token) = token {
16 builder = builder.auth_token(token);
17 }
18 if let Some(client_name) = client_name {
19 builder = builder.client_name(client_name);
20 }
21
22 let mut client = builder.connect()?;
23
24 match action.as_str() {
25 "status" => {
26 let status = client.get_status()?;
27 println!("{:#?}", status);
28 }
29 "workers" => {
30 let workers = client.get_workers()?;
31 println!("{:#?}", workers);
32 }
33 "show-config" => {
34 let config = client.show_config()?;
35 println!("{}", config);
36 }
37 "scale" => {
38 let workers = args
39 .next()
40 .ok_or("scale requires worker count")?
41 .parse::<usize>()?;
42 let message = client.scale_to(workers)?;
43 println!("{}", message);
44 }
45 "restart" => {
46 let id = args.next().and_then(|value| value.parse::<u32>().ok());
47 let force = args.any(|value| value == "--force");
48 let message = client.restart_worker(id, !force)?;
49 println!("{}", message);
50 }
51 "shutdown" => {
52 let force = args.any(|value| value == "--force");
53 let message = client.shutdown(!force)?;
54 println!("{}", message);
55 }
56 "reload" => {
57 let mut path = None;
58 let mut rolling = true;
59 for value in args {
60 if value == "--no-rolling" {
61 rolling = false;
62 } else if value.starts_with("--path=") {
63 path = value.split('=').nth(1).map(|s| s.to_string());
64 } else if path.is_none() {
65 path = Some(value);
66 }
67 }
68 let message = client.reload_config(path, rolling)?;
69 println!("{}", message);
70 }
71 other => {
72 eprintln!(
73 "Unknown action: {} (use status|workers|show-config|scale|restart|shutdown|reload)",
74 other
75 );
76 }
77 }
78
79 Ok(())
80}Auto Trait Implementations§
impl Freeze for ControlClient
impl RefUnwindSafe for ControlClient
impl Send for ControlClient
impl Sync for ControlClient
impl Unpin for ControlClient
impl UnsafeUnpin for ControlClient
impl UnwindSafe for ControlClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more