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