mirror of
https://github.com/denoland/deno.git
synced 2025-01-20 20:42:19 -05:00
use env var
This commit is contained in:
parent
e1c707e661
commit
18ded442ac
7 changed files with 40 additions and 60 deletions
|
@ -627,7 +627,6 @@ pub struct Flags {
|
|||
pub code_cache_enabled: bool,
|
||||
pub permissions: PermissionFlags,
|
||||
pub allow_scripts: PackagesAllowedScripts,
|
||||
pub internal_use_lsc_cache: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Default, Serialize, Deserialize)]
|
||||
|
@ -3765,12 +3764,6 @@ fn runtime_misc_args(app: Command) -> Command {
|
|||
.arg(seed_arg())
|
||||
.arg(enable_testing_features_arg())
|
||||
.arg(strace_ops_arg())
|
||||
.arg(
|
||||
Arg::new("internal-use-lsc-cache")
|
||||
.long("internal-use-lsc-cache")
|
||||
.action(ArgAction::SetTrue)
|
||||
.hide(true),
|
||||
)
|
||||
}
|
||||
|
||||
fn allow_import_arg() -> Arg {
|
||||
|
@ -5641,7 +5634,6 @@ fn runtime_args_parse(
|
|||
allow_scripts_arg_parse(flags, matches)?;
|
||||
}
|
||||
location_arg_parse(flags, matches);
|
||||
flags.internal_use_lsc_cache = matches.get_flag("internal-use-lsc-cache");
|
||||
v8_flags_arg_parse(flags, matches);
|
||||
seed_arg_parse(flags, matches);
|
||||
enable_testing_features_arg_parse(flags, matches);
|
||||
|
|
|
@ -1662,10 +1662,6 @@ impl CliOptions {
|
|||
&self.flags.v8_flags
|
||||
}
|
||||
|
||||
pub fn use_lsc_cache(&self) -> bool {
|
||||
self.flags.internal_use_lsc_cache
|
||||
}
|
||||
|
||||
pub fn code_cache_enabled(&self) -> bool {
|
||||
self.flags.code_cache_enabled
|
||||
}
|
||||
|
|
|
@ -1131,7 +1131,6 @@ impl CliFactory {
|
|||
pkg_json_resolver,
|
||||
self.root_cert_store_provider().clone(),
|
||||
cli_options.resolve_storage_key_resolver(),
|
||||
cli_options.use_lsc_cache(),
|
||||
self.sys(),
|
||||
self.create_lib_main_worker_options()?,
|
||||
);
|
||||
|
|
|
@ -196,7 +196,6 @@ struct LibWorkerFactorySharedState<TSys: DenoLibSys> {
|
|||
root_cert_store_provider: Arc<dyn RootCertStoreProvider>,
|
||||
shared_array_buffer_store: SharedArrayBufferStore,
|
||||
storage_key_resolver: StorageKeyResolver,
|
||||
use_lsc_cache: bool,
|
||||
sys: TSys,
|
||||
options: LibMainWorkerOptions,
|
||||
}
|
||||
|
@ -327,7 +326,6 @@ impl<TSys: DenoLibSys> LibWorkerFactorySharedState<TSys> {
|
|||
worker_type: args.worker_type,
|
||||
stdio: stdio.clone(),
|
||||
cache_storage_dir,
|
||||
use_lsc_cache: shared.use_lsc_cache,
|
||||
strace_ops: shared.options.strace_ops.clone(),
|
||||
close_on_idle: args.close_on_idle,
|
||||
maybe_worker_metadata: args.maybe_worker_metadata,
|
||||
|
@ -359,7 +357,6 @@ impl<TSys: DenoLibSys> LibMainWorkerFactory<TSys> {
|
|||
pkg_json_resolver: Arc<node_resolver::PackageJsonResolver<TSys>>,
|
||||
root_cert_store_provider: Arc<dyn RootCertStoreProvider>,
|
||||
storage_key_resolver: StorageKeyResolver,
|
||||
use_lsc_cache: bool,
|
||||
sys: TSys,
|
||||
options: LibMainWorkerOptions,
|
||||
) -> Self {
|
||||
|
@ -379,7 +376,6 @@ impl<TSys: DenoLibSys> LibMainWorkerFactory<TSys> {
|
|||
root_cert_store_provider,
|
||||
shared_array_buffer_store: Default::default(),
|
||||
storage_key_resolver,
|
||||
use_lsc_cache,
|
||||
sys,
|
||||
options,
|
||||
}),
|
||||
|
@ -504,7 +500,6 @@ impl<TSys: DenoLibSys> LibMainWorkerFactory<TSys> {
|
|||
should_wait_for_inspector_session: shared.options.inspect_wait,
|
||||
strace_ops: shared.options.strace_ops.clone(),
|
||||
cache_storage_dir,
|
||||
use_lsc_cache: shared.use_lsc_cache,
|
||||
origin_storage_dir,
|
||||
stdio,
|
||||
skip_op_registration: shared.options.skip_op_registration,
|
||||
|
|
|
@ -945,7 +945,6 @@ pub async fn run(
|
|||
pkg_json_resolver,
|
||||
root_cert_store_provider,
|
||||
StorageKeyResolver::empty(),
|
||||
false,
|
||||
sys.clone(),
|
||||
lib_main_worker_options,
|
||||
);
|
||||
|
|
|
@ -376,7 +376,6 @@ pub struct WebWorkerOptions {
|
|||
pub format_js_error_fn: Option<Arc<FormatJsErrorFn>>,
|
||||
pub worker_type: WebWorkerType,
|
||||
pub cache_storage_dir: Option<std::path::PathBuf>,
|
||||
pub use_lsc_cache: bool,
|
||||
pub stdio: Stdio,
|
||||
pub strace_ops: Option<Vec<String>>,
|
||||
pub close_on_idle: bool,
|
||||
|
@ -456,24 +455,15 @@ impl WebWorker {
|
|||
let enable_testing_features = options.bootstrap.enable_testing_features;
|
||||
|
||||
fn create_cache_inner(options: &WebWorkerOptions) -> Option<CreateCache> {
|
||||
if let Some(storage_dir) = &options.cache_storage_dir {
|
||||
let storage_dir = storage_dir.clone();
|
||||
let create_cache_fn = move || {
|
||||
let s = SqliteBackedCache::new(storage_dir.clone())?;
|
||||
Ok(CacheImpl::Sqlite(s))
|
||||
};
|
||||
return Some(CreateCache(Arc::new(create_cache_fn)));
|
||||
}
|
||||
|
||||
if options.use_lsc_cache {
|
||||
if let Ok(var) = std::env::var("DENO_CACHE_LSC_ENDPOINT") {
|
||||
let elems: Vec<_> = var.split(",").collect();
|
||||
if elems.len() == 2 {
|
||||
let endpoint = elems[0];
|
||||
let token = elems[1];
|
||||
use deno_cache::CacheShard;
|
||||
let Ok(endpoint) = std::env::var("LSC_ENDPOINT") else {
|
||||
return None;
|
||||
};
|
||||
let Ok(token) = std::env::var("LSC_TOKEN") else {
|
||||
return None;
|
||||
};
|
||||
let shard = Rc::new(CacheShard::new(endpoint, token));
|
||||
|
||||
let shard =
|
||||
Rc::new(CacheShard::new(endpoint.to_string(), token.to_string()));
|
||||
let create_cache_fn = move || {
|
||||
let x = deno_cache::LscBackend::default();
|
||||
x.set_shard(shard.clone());
|
||||
|
@ -483,6 +473,16 @@ impl WebWorker {
|
|||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
return Some(CreateCache(Arc::new(create_cache_fn)));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(storage_dir) = &options.cache_storage_dir {
|
||||
let storage_dir = storage_dir.clone();
|
||||
let create_cache_fn = move || {
|
||||
let s = SqliteBackedCache::new(storage_dir.clone())?;
|
||||
Ok(CacheImpl::Sqlite(s))
|
||||
};
|
||||
return Some(CreateCache(Arc::new(create_cache_fn)));
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
|
|
@ -200,7 +200,6 @@ pub struct WorkerOptions {
|
|||
pub strace_ops: Option<Vec<String>>,
|
||||
|
||||
pub cache_storage_dir: Option<std::path::PathBuf>,
|
||||
pub use_lsc_cache: bool,
|
||||
pub origin_storage_dir: Option<std::path::PathBuf>,
|
||||
pub stdio: Stdio,
|
||||
pub enable_stack_trace_arg_in_ops: bool,
|
||||
|
@ -222,7 +221,6 @@ impl Default for WorkerOptions {
|
|||
format_js_error_fn: Default::default(),
|
||||
origin_storage_dir: Default::default(),
|
||||
cache_storage_dir: Default::default(),
|
||||
use_lsc_cache: false,
|
||||
extensions: Default::default(),
|
||||
startup_snapshot: Default::default(),
|
||||
create_params: Default::default(),
|
||||
|
@ -344,24 +342,15 @@ impl MainWorker {
|
|||
);
|
||||
|
||||
fn create_cache_inner(options: &WorkerOptions) -> Option<CreateCache> {
|
||||
if let Some(storage_dir) = &options.cache_storage_dir {
|
||||
let storage_dir = storage_dir.clone();
|
||||
let create_cache_fn = move || {
|
||||
let s = SqliteBackedCache::new(storage_dir.clone())?;
|
||||
Ok(CacheImpl::Sqlite(s))
|
||||
};
|
||||
return Some(CreateCache(Arc::new(create_cache_fn)));
|
||||
}
|
||||
|
||||
if options.use_lsc_cache {
|
||||
if let Ok(var) = std::env::var("DENO_CACHE_LSC_ENDPOINT") {
|
||||
let elems: Vec<_> = var.split(",").collect();
|
||||
if elems.len() == 2 {
|
||||
let endpoint = elems[0];
|
||||
let token = elems[1];
|
||||
use deno_cache::CacheShard;
|
||||
let Ok(endpoint) = std::env::var("LSC_ENDPOINT") else {
|
||||
return None;
|
||||
};
|
||||
let Ok(token) = std::env::var("LSC_TOKEN") else {
|
||||
return None;
|
||||
};
|
||||
let shard = Rc::new(CacheShard::new(endpoint, token));
|
||||
|
||||
let shard =
|
||||
Rc::new(CacheShard::new(endpoint.to_string(), token.to_string()));
|
||||
let create_cache_fn = move || {
|
||||
let x = deno_cache::LscBackend::default();
|
||||
x.set_shard(shard.clone());
|
||||
|
@ -371,6 +360,16 @@ impl MainWorker {
|
|||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
return Some(CreateCache(Arc::new(create_cache_fn)));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(storage_dir) = &options.cache_storage_dir {
|
||||
let storage_dir = storage_dir.clone();
|
||||
let create_cache_fn = move || {
|
||||
let s = SqliteBackedCache::new(storage_dir.clone())?;
|
||||
Ok(CacheImpl::Sqlite(s))
|
||||
};
|
||||
return Some(CreateCache(Arc::new(create_cache_fn)));
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue