mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
make OsApi manager-based
This commit is contained in:
@@ -4,7 +4,7 @@ use std::time::Duration;
|
||||
|
||||
use color_eyre::eyre::eyre;
|
||||
use embassy_container_init::{ProcessGroupId, SignalGroup, SignalGroupParams};
|
||||
use helpers::{Callback, OsApi, UnixRpcClient};
|
||||
use helpers::{OsApi, UnixRpcClient};
|
||||
pub use js_engine::JsError;
|
||||
use js_engine::{JsExecutionEnvironment, PathForVolumeId};
|
||||
use models::{ErrorKind, VolumeId};
|
||||
@@ -19,18 +19,6 @@ use crate::util::{GeneralGuard, Version};
|
||||
use crate::volume::Volumes;
|
||||
use crate::Error;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl OsApi for RpcContext {
|
||||
async fn get_service_config(
|
||||
&self,
|
||||
id: PackageId,
|
||||
path: &str,
|
||||
callback: Callback,
|
||||
) -> Result<serde_json::Value, Error> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
|
||||
@@ -57,6 +45,12 @@ impl PathForVolumeId for Volumes {
|
||||
}
|
||||
}
|
||||
|
||||
struct SandboxOsApi {
|
||||
_ctx: RpcContext,
|
||||
}
|
||||
#[async_trait::async_trait]
|
||||
impl OsApi for SandboxOsApi {}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct JsProcedure {
|
||||
@@ -138,7 +132,7 @@ impl JsProcedure {
|
||||
) -> Result<Result<O, (i32, String)>, Error> {
|
||||
Ok(async move {
|
||||
let running_action = JsExecutionEnvironment::load_from_package(
|
||||
Arc::new(ctx.clone()),
|
||||
Arc::new(SandboxOsApi { _ctx: ctx.clone() }),
|
||||
&ctx.datadir,
|
||||
pkg_id,
|
||||
pkg_version,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use color_eyre::eyre::eyre;
|
||||
@@ -96,7 +95,6 @@ impl PackageProcedure {
|
||||
})?;
|
||||
let gid;
|
||||
let rpc_client = man.rpc_client();
|
||||
let os = Arc::new(ctx.clone());
|
||||
if matches!(name, ProcedureName::Main) {
|
||||
gid = man.gid.new_main_gid();
|
||||
} else {
|
||||
@@ -114,7 +112,7 @@ impl PackageProcedure {
|
||||
timeout,
|
||||
gid,
|
||||
rpc_client,
|
||||
os,
|
||||
man,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user