Skip to content

Commit b62e75c

Browse files
committed
node: Add graphman config setting
1 parent 947d825 commit b62e75c

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

node/src/bin/manager.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,15 @@ pub enum ConfigCommand {
383383
features: String,
384384
network: String,
385385
},
386+
/// Show subgraph-specific settings
387+
///
388+
/// GRAPH_EXPERIMENTAL_SUBGRAPH_SETTINGS can add a file that contains
389+
/// subgraph-specific settings. This command determines which settings
390+
/// would apply when a subgraph <name> is deployed and prints the result
391+
Setting {
392+
/// The subgraph name for which to print settings
393+
name: String,
394+
},
386395
}
387396

388397
#[derive(Clone, Debug, Subcommand)]
@@ -1079,6 +1088,7 @@ async fn main() -> anyhow::Result<()> {
10791088
commands::config::provider(logger, &ctx.config, registry, features, network)
10801089
.await
10811090
}
1091+
Setting { name } => commands::config::setting(&name),
10821092
}
10831093
}
10841094
Remove { name } => commands::remove::run(ctx.subgraph_store(), &name),

node/src/manager/commands/config.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use std::{collections::BTreeMap, sync::Arc};
22

33
use graph::{
4-
anyhow::bail,
5-
components::subgraph::Settings,
4+
anyhow::{bail, Context},
5+
components::subgraph::{Setting, Settings},
66
endpoint::EndpointMetrics,
77
env::EnvVars,
88
itertools::Itertools,
99
prelude::{
1010
anyhow::{anyhow, Error},
11-
MetricsRegistry, NodeId,
11+
MetricsRegistry, NodeId, SubgraphName,
1212
},
1313
slog::Logger,
1414
};
@@ -158,3 +158,25 @@ pub async fn provider(
158158
);
159159
Ok(())
160160
}
161+
162+
pub fn setting(name: &str) -> Result<(), Error> {
163+
let name = SubgraphName::new(name).map_err(|()| anyhow!("illegal subgraph name `{}`", name))?;
164+
let env_vars = EnvVars::from_env().unwrap();
165+
if let Some(path) = &env_vars.subgraph_settings {
166+
let settings = Settings::from_file(path)
167+
.with_context(|| format!("syntax error in subgraph settings `{}`", path))?;
168+
match settings.for_name(&name) {
169+
Some(Setting { history_blocks, .. }) => {
170+
println!("setting for `{name}` will use history_blocks = {history_blocks}");
171+
}
172+
None => {
173+
println!("no specific setting for `{name}`, defaults will be used");
174+
}
175+
}
176+
} else {
177+
println!("No subgraph-specific settings will be applied because");
178+
println!("GRAPH_EXPERIMENTAL_SUBGRAPH_SETTINGS is not set");
179+
};
180+
181+
Ok(())
182+
}

0 commit comments

Comments
 (0)