mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-19 01:36:15 +00:00
Merge branch 'next-v2' into 1686a/s3-redirects
This commit is contained in:
@@ -6,7 +6,6 @@ pub mod worker;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::{mpsc, watch};
|
||||
|
||||
use worker::WorkerProcessor;
|
||||
@@ -18,7 +17,7 @@ pub struct BackgroundRunner {
|
||||
worker_info: Arc<std::sync::Mutex<HashMap<usize, WorkerInfo>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct WorkerInfo {
|
||||
pub name: String,
|
||||
pub status: WorkerStatus,
|
||||
@@ -30,7 +29,7 @@ pub struct WorkerInfo {
|
||||
|
||||
/// WorkerStatus is a struct returned by the worker with a bunch of canonical
|
||||
/// fields to indicate their status to CLI users. All fields are optional.
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct WorkerStatus {
|
||||
pub tranquility: Option<u32>,
|
||||
pub progress: Option<String>,
|
||||
|
||||
@@ -6,7 +6,6 @@ use async_trait::async_trait;
|
||||
use futures::future::*;
|
||||
use futures::stream::FuturesUnordered;
|
||||
use futures::StreamExt;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::select;
|
||||
use tokio::sync::{mpsc, watch};
|
||||
|
||||
@@ -18,7 +17,7 @@ use crate::time::now_msec;
|
||||
// will be interrupted in the middle of whatever they are doing.
|
||||
const EXIT_DEADLINE: Duration = Duration::from_secs(8);
|
||||
|
||||
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize, Debug)]
|
||||
#[derive(PartialEq, Copy, Clone, Debug)]
|
||||
pub enum WorkerState {
|
||||
Busy,
|
||||
Throttled(f32),
|
||||
@@ -26,17 +25,6 @@ pub enum WorkerState {
|
||||
Done,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for WorkerState {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
WorkerState::Busy => write!(f, "Busy"),
|
||||
WorkerState::Throttled(_) => write!(f, "Busy*"),
|
||||
WorkerState::Idle => write!(f, "Idle"),
|
||||
WorkerState::Done => write!(f, "Done"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait Worker: Send {
|
||||
fn name(&self) -> String;
|
||||
|
||||
Reference in New Issue
Block a user