Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3369103
D8835.id30017.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D8835.id30017.diff
View Options
diff --git a/services/blob/src/config.rs b/services/blob/src/config.rs
--- a/services/blob/src/config.rs
+++ b/services/blob/src/config.rs
@@ -1,11 +1,11 @@
use anyhow::{ensure, Result};
-use clap::{builder::FalseyValueParser, Parser};
+use clap::Parser;
use once_cell::sync::Lazy;
use tracing::info;
use crate::constants::{
- DEFAULT_GRPC_PORT, DEFAULT_HTTP_PORT, DEFAULT_S3_BUCKET_NAME, LOCALSTACK_URL,
- S3_BUCKET_ENV_VAR, SANDBOX_ENV_VAR,
+ DEFAULT_GRPC_PORT, DEFAULT_HTTP_PORT, DEFAULT_S3_BUCKET_NAME,
+ S3_BUCKET_ENV_VAR,
};
#[derive(Parser)]
@@ -17,15 +17,10 @@
/// HTTP server listening port
#[arg(long, default_value_t = DEFAULT_HTTP_PORT)]
pub http_port: u16,
- /// Run the service in sandbox
- #[arg(long = "sandbox", default_value_t = false)]
- // support the env var for compatibility reasons
- #[arg(env = SANDBOX_ENV_VAR)]
- #[arg(value_parser = FalseyValueParser::new())]
- pub is_sandbox: bool,
- /// AWS Localstack service URL, applicable in sandbox mode
- #[arg(long, default_value_t = LOCALSTACK_URL.to_string())]
- pub localstack_url: String,
+ /// AWS Localstack service URL
+ #[arg(env = "LOCALSTACK_ENDPOINT")]
+ #[arg(long)]
+ pub localstack_endpoint: Option<String>,
#[arg(env = S3_BUCKET_ENV_VAR)]
#[arg(long, default_value_t = DEFAULT_S3_BUCKET_NAME.to_string())]
pub s3_bucket_name: String,
@@ -58,12 +53,9 @@
pub async fn load_aws_config() -> aws_types::SdkConfig {
let mut config_builder = aws_config::from_env();
- if CONFIG.is_sandbox {
- info!(
- "Running in sandbox environment. Localstack URL: {}",
- &CONFIG.localstack_url
- );
- config_builder = config_builder.endpoint_url(&CONFIG.localstack_url);
+ if let Some(endpoint) = &CONFIG.localstack_endpoint {
+ info!("Using Localstack. AWS endpoint URL: {}", endpoint);
+ config_builder = config_builder.endpoint_url(endpoint);
}
config_builder.load().await
diff --git a/services/blob/src/constants.rs b/services/blob/src/constants.rs
--- a/services/blob/src/constants.rs
+++ b/services/blob/src/constants.rs
@@ -2,7 +2,6 @@
pub const DEFAULT_GRPC_PORT: u16 = 50051;
pub const DEFAULT_HTTP_PORT: u16 = 51001;
-pub const LOCALSTACK_URL: &str = "http://localstack:4566";
pub const MPSC_CHANNEL_BUFFER_CAPACITY: usize = 1;
/// 4MB limit
@@ -64,7 +63,6 @@
// Environment variables
-pub const SANDBOX_ENV_VAR: &str = "COMM_SERVICES_SANDBOX";
pub const LOG_LEVEL_ENV_VAR: &str =
tracing_subscriber::filter::EnvFilter::DEFAULT_ENV;
diff --git a/services/blob/src/http/mod.rs b/services/blob/src/http/mod.rs
--- a/services/blob/src/http/mod.rs
+++ b/services/blob/src/http/mod.rs
@@ -13,7 +13,8 @@
}
fn cors_config() -> Cors {
- if CONFIG.is_sandbox {
+ // For local development, use relaxed CORS config
+ if CONFIG.localstack_endpoint.is_some() {
// All origins, methods, request headers and exposed headers allowed.
// Credentials supported. Max age 1 hour. Does not send wildcard.
return Cors::permissive();
diff --git a/services/blob/src/s3.rs b/services/blob/src/s3.rs
--- a/services/blob/src/s3.rs
+++ b/services/blob/src/s3.rs
@@ -107,7 +107,7 @@
pub fn new(aws_config: &aws_types::SdkConfig) -> Self {
let s3_config = aws_sdk_s3::config::Builder::from(aws_config)
// localstack doesn't support virtual addressing
- .force_path_style(crate::config::CONFIG.is_sandbox)
+ .force_path_style(crate::config::CONFIG.localstack_endpoint.is_some())
.build();
S3Client {
client: Arc::new(aws_sdk_s3::Client::from_conf(s3_config)),
diff --git a/services/blob/src/tools.rs b/services/blob/src/tools.rs
--- a/services/blob/src/tools.rs
+++ b/services/blob/src/tools.rs
@@ -1,18 +1,6 @@
-use std::{env, error::Error as StdError};
+use std::error::Error as StdError;
use tonic::codegen::futures_core::Stream;
-use crate::constants;
-
-fn is_env_flag_set(env_var_name: &str) -> bool {
- let flag_value = env::var(env_var_name).unwrap_or_default().to_lowercase();
- return ["1", "true"].contains(&flag_value.as_str());
-}
-
-/// Returns true if the `COMM_SERVICES_SANDBOX` environment variable is set
-pub fn is_sandbox_env() -> bool {
- return is_env_flag_set(constants::SANDBOX_ENV_VAR);
-}
-
pub type BoxedError = Box<dyn StdError>;
// Trait type aliases aren't supported in Rust, but
// we can workaround this by creating an empty trait
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 9:46 PM (15 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2586437
Default Alt Text
D8835.id30017.diff (4 KB)
Attached To
Mode
D8835: [blob-service] Standardize localstack config
Attached
Detach File
Event Timeline
Log In to Comment