ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/salaryman/trunk/src/smd/context.rs
Revision: 14
Committed: Sat Jul 12 06:17:38 2025 UTC (2 months, 4 weeks ago) by yuzu
File size: 1116 byte(s)
Log Message:
add start, stop, restart endpoints

File Contents

# Content
1 use salaryman::service::{Service, ServiceConf};
2 use schemars::JsonSchema;
3 use serde::{Deserialize, Serialize};
4 use std::sync::Arc;
5 use tokio::sync::Mutex;
6 use uuid::Uuid;
7
8 pub struct SalarymanService {
9 pub config: ServiceConf,
10 pub service: Arc<Mutex<Service>>,
11 }
12 impl SalarymanService {
13 pub fn new() -> Self {
14 Self {
15 config: ServiceConf::new(),
16 service: Arc::new(Mutex::new(Service::new())),
17 }
18 }
19 pub fn from_parts(config: ServiceConf, service: Arc<Mutex<Service>>) -> Self {
20 Self { config, service }
21 }
22 }
23
24 pub struct SalarymanDContext {
25 pub services: Vec<Arc<SalarymanService>>,
26 }
27 impl SalarymanDContext {
28 pub fn new() -> Self {
29 Self {
30 services: Vec::new(),
31 }
32 }
33 pub fn from_vec(services: Vec<Arc<SalarymanService>>) -> Self {
34 Self { services }
35 }
36 }
37
38 #[derive(Serialize, Deserialize, JsonSchema, Debug)]
39 pub struct StdinBuffer {
40 pub stdin: String,
41 pub endl: Option<bool>,
42 }
43
44 #[derive(Serialize, Deserialize, JsonSchema, Debug)]
45 pub struct ServicePath {
46 pub service_uuid: Uuid,
47 }