Skip to content

Commit

Permalink
refactor: config renaming for file-service
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Mar 7, 2024
1 parent 6adcb0e commit 83a7b2d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions file-exchange/tests/test0.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[server]
bundles = ["QmeaPp764FjQjPB66M9ijmQKmLhwBpHQhA7dEbH2FA1j3v:"]
initial_bundles = ["QmeaPp764FjQjPB66M9ijmQKmLhwBpHQhA7dEbH2FA1j3v:"]
admin_auth_token = "slayyy"
admin_host_and_port = "0.0.0.0:5664"
price_per_byte = 1
default_price_per_byte = 1
ipfs_gateway = "https://ipfs.network.thegraph.com"
log_format = "Full"
[server.storage_method.LocalFiles]
Expand Down
4 changes: 2 additions & 2 deletions file-exchange/tests/test1.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[server]
bundles = [
initial_bundles = [
"QmVPPWWaraEvoc4LCrYXtMbL13WPNbnuXV2yo7W8zexFGq:",
"QmeD3dRVV6Gs84TRwiNj3tLt9mBEMVqy3GoWm7WN8oDzGz:",
"QmTSwj1BGkkmVSnhw6uEGkcxGZvP5nq4pDhzHjwJvsQC2Z:"
]
admin_auth_token = "kueen"
admin_host_and_port = "0.0.0.0:5665"
price_per_byte = 1
default_price_per_byte = 1
ipfs_gateway = "https://ipfs.network.thegraph.com"
log_format = "Pretty"
[server.storage_method.LocalFiles]
Expand Down
22 changes: 11 additions & 11 deletions file-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ pub struct ServerArgs {
// Taking from config right now, later can read from DB table for managing server states
#[arg(
long,
value_name = "BUNDLES",
env = "BUNDLES",
value_name = "initial-bundles",
env = "INITIAL_BUNDLES",
value_delimiter = ',',
help = "Comma separated list of IPFS hashes and shared prefix of files in the bundles (empty if just in main_directory) to serve upon start-up; format: [ipfs_hash:prefix]"
help = "Comma separated list of IPFS hashes and shared prefix of files in the bundles (empty if just in main_directory) to serve upon start-up; the list can be managed through the /admin API without service restart.\nformat: [ipfs_hash:prefix]"
)]
pub bundles: Vec<String>,
pub initial_bundles: Vec<String>,
#[clap(
long,
value_name = "admin-auth-token",
Expand All @@ -48,15 +48,15 @@ pub struct ServerArgs {
//TODO: More complex price management
#[arg(
long,
value_name = "ADMIN_ADDR",
value_name = "admin-addr",
default_value = "0.0.0.0/6700",
env = "ADMIN_ADDR",
help = "Expost Admin service at address with both host and port"
)]
pub admin_host_and_port: SocketAddr,
#[arg(
long,
value_name = "IPFS_GATEWAY_URL",
value_name = "ipfs-gateway-url",
default_value = "https://ipfs.network.thegraph.com",
env = "IPFS_GATEWAY_URL",
help = "IPFS gateway to interact with"
Expand All @@ -66,7 +66,7 @@ pub struct ServerArgs {
pub storage_method: StorageMethod,
#[arg(
long,
value_name = "LOG_FORMAT",
value_name = "log-format",
env = "LOG_FORMAT",
help = "Support logging formats: pretty, json, full, compact",
long_help = "pretty: verbose and human readable; json: not verbose and parsable; compact: not verbose and not parsable; full: verbose and not parsible",
Expand All @@ -76,12 +76,12 @@ pub struct ServerArgs {
//TODO: More complex price management
#[arg(
long,
value_name = "PRICE_PER_BYTE",
value_name = "default-price-per-byte",
default_value = "1",
env = "PRICE_PER_BYTE",
help = "Price per byte in GRT"
env = "DEFAULT_PRICE_PER_BYTE",
help = "Default price per byte in GRT"
)]
pub price_per_byte: f64,
pub default_price_per_byte: f64,
}

#[derive(clap::ValueEnum, Clone, Debug, Serialize, Deserialize, Default)]
Expand Down
4 changes: 2 additions & 2 deletions file-service/src/file_server/cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Query {
.state
.config
.server
.price_per_byte;
.default_price_per_byte;
let cost_models = deployments
.into_iter()
.map(|s| GraphQlCostModel {
Expand Down Expand Up @@ -60,7 +60,7 @@ impl Query {
.state
.config
.server
.price_per_byte;
.default_price_per_byte;
GraphQlCostModel {
deployment,
price_per_byte: price,
Expand Down
2 changes: 1 addition & 1 deletion file-service/src/file_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub async fn initialize_server_context(config: Config) -> Result<ServerContext,
} else {
IpfsClient::localhost()
};
let bundle_entries = validate_bundle_entries(config.server.bundles.clone())?;
let bundle_entries = validate_bundle_entries(config.server.initial_bundles.clone())?;
tracing::debug!(
entries = tracing::field::debug(&bundle_entries),
"Validated bundle entries"
Expand Down
4 changes: 2 additions & 2 deletions template.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ chain_id = 421614
receipts_verifier_address = "0xfC24cE7a4428A6B89B52645243662A02BA734ECF"

[server]
bundles = ["QmHash00:./example-file/","QmHash01:BUNDLE_PATH"]
initial_bundles = ["QmHash00:./example-file/","QmHash01:BUNDLE_PATH"]
admin_auth_token = "kueen"
price_per_byte = 1
default_price_per_byte = 1
ipfs_gateway = "https://ipfs.network.thegraph.com"
log_format = "Pretty"

0 comments on commit 83a7b2d

Please sign in to comment.