Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update rust crate axum to 0.7.3 #29

Merged
merged 6 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 141 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ path = "src/bin/rustic-scheduler-client.rs"

[dependencies]
anyhow = "1"
axum = { version = "0.6.20", features = ["ws"] }
axum = { version = "0.7.3", features = ["ws"] }
chrono = "0.4.31"
clap = "4"
clap_derive = "4.4.7"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ It allows to define client groups which are all backed up the same way.
- Copy the `rustic-scheduler-server` binary to your backup schedule server and
the `rustic-scheduler-client` binary to all your clients (available under
`/targets/release`).
- Create a config file `rustic_schedulder.toml` on your backup schedule server
(example config is available in the `config/` dir)
- Create a config file `./config/rustic_schedulder.toml` on your backup schedule
server (example config is available in the `config/` dir)
- Run the `rustic-scheduler-server` binary on your server in the dir containing
the config.
- On each client, run `rustic-scheduler-client <ADDR>`, where `<ADDR>` is the
Expand Down
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fmt:
cargo fmt --all
dprint fmt
14 changes: 9 additions & 5 deletions src/bin/rustic-scheduler-server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::{collections::HashMap, fs::read_to_string, time::Duration};

use anyhow::Result;
use axum::{
extract::{
Expand All @@ -13,7 +11,9 @@ use axum::{
use chrono::Local;
use log::warn;
use sailfish::TemplateOnce;
use std::{collections::HashMap, fs::read_to_string, time::Duration};
use tokio::{
net::TcpListener,
spawn,
sync::{mpsc, oneshot},
time::sleep,
Expand Down Expand Up @@ -47,7 +47,8 @@ enum NotifyMessage {

#[tokio::main]
async fn main() {
let config = read_to_string("rustic_scheduler.toml").unwrap();
// FIXME: Unhardcode config file and expose via CLI settings
let config = read_to_string("./config/rustic_scheduler.toml").unwrap();
let config: ConfigFile = toml::from_str(&config).unwrap();
config.validate().unwrap();

Expand Down Expand Up @@ -145,8 +146,11 @@ async fn main() {
.with_state(wtx);

// run it with hyper on localhost:3012
axum::Server::bind(&config.global.address.parse().unwrap())
.serve(app.into_make_service())
let listener = TcpListener::bind(&config.global.address).await.unwrap();

println!("Listening on http://{}", config.global.address);

axum::serve(listener, app.into_make_service())
.await
.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Client {
fn next_invocation(&self) -> Option<Time> {
match self.state {
ClientState::Idle | ClientState::NotConnected => {
self.sources.get(0).and_then(|s| s.next_invocation)
self.sources.first().and_then(|s| s.next_invocation)
}
ClientState::Processing(_) => None,
}
Expand Down