mirror of
https://github.com/OMGeeky/gdriver2.git
synced 2026-02-15 22:14:31 +01:00
misc
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
use super::*;
|
||||
use crate::prelude::*;
|
||||
use confique::{Config, Layer};
|
||||
use std::net::{IpAddr, Ipv6Addr};
|
||||
const IP_DEFAULT: IpAddr = IpAddr::V6(Ipv6Addr::LOCALHOST);
|
||||
#[derive(Debug, Serialize, Deserialize, Config, Clone)]
|
||||
pub struct Configuration {
|
||||
#[config(default = 33333)]
|
||||
pub port: u16,
|
||||
// #[config(default = Test)]
|
||||
pub ip: std::net::IpAddr,
|
||||
#[config(default = "\0gdriver2_v3.sock")]
|
||||
pub socket_path: String,
|
||||
}
|
||||
pub fn load_config() -> Result<Configuration> {
|
||||
Ok(add_default_locations(Config::builder()).load()?)
|
||||
@@ -19,12 +15,7 @@ pub fn load_config_with_path(path: &Path) -> Result<Configuration> {
|
||||
fn add_default_locations(
|
||||
builder: confique::Builder<Configuration>,
|
||||
) -> confique::Builder<Configuration> {
|
||||
type P = <Configuration as Config>::Layer;
|
||||
let prebuilt = P {
|
||||
ip: Some(IP_DEFAULT),
|
||||
..P::empty()
|
||||
};
|
||||
builder.env().file("config.toml").preloaded(prebuilt)
|
||||
builder.env().file("config.toml")
|
||||
}
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
@@ -29,8 +29,29 @@ pub trait GDriverService {
|
||||
/// Returns true if the file was had remote changes and was updated
|
||||
async fn update_changes_for_file(id: DriveId) -> StdResult<bool, UpdateChangesError>;
|
||||
async fn update_changes() -> StdResult<(), UpdateChangesError>;
|
||||
async fn do_something2(req: BackendActionRequest) -> StdResult<String, BackendActionError>;
|
||||
async fn do_something2(req: BackendActionRequest) -> StdResult<AsyncResponse<String>, BackendActionError>;
|
||||
}
|
||||
|
||||
#[tarpc::service]
|
||||
pub trait GDriverClient {
|
||||
async fn report_task_result(id: TaskId, result: TaskResult);
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct TaskId(pub String);
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum AsyncResponse<T> {
|
||||
Immediate(T),
|
||||
Pending(TaskId),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum TaskResult {
|
||||
Success(String),
|
||||
Error(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum BackendActionRequest {
|
||||
ShutdownGracefully,
|
||||
|
||||
Reference in New Issue
Block a user