Skip to content

Commit

Permalink
graphman: Add
Browse files Browse the repository at this point in the history
  • Loading branch information
leoyvens committed May 1, 2021
1 parent c6226ac commit ef2a492
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions node/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ pub enum Command {
/// The name of the subgraph to remove
name: String,
},
/// Create a subgraph name
Create {
/// The name of the subgraph to create
name: String,
},
/// Assign or reassign a deployment
Reassign {
/// The id of the deployment to reassign
Expand Down Expand Up @@ -453,6 +458,7 @@ async fn main() {
}
}
Remove { name } => commands::remove::run(ctx.subgraph_store(), name),
Create { name } => commands::create::run(ctx.subgraph_store(), name),
Unassign { id, shard } => commands::assign::unassign(ctx.subgraph_store(), id, shard),
Reassign { id, node, shard } => {
commands::assign::reassign(ctx.subgraph_store(), id, node, shard)
Expand Down
14 changes: 14 additions & 0 deletions node/src/manager/commands/create.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::sync::Arc;

use graph::prelude::{anyhow, Error, SubgraphName, SubgraphStore as _};
use graph_store_postgres::SubgraphStore;

pub fn run(store: Arc<SubgraphStore>, name: String) -> Result<(), Error> {
let name = SubgraphName::new(name.clone())
.map_err(|()| anyhow!("illegal subgraph name `{}`", name))?;

println!("creating subgraph {}", name);
store.create_subgraph(name)?;

Ok(())
}
1 change: 1 addition & 0 deletions node/src/manager/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod assign;
pub mod config;
pub mod copy;
pub mod create;
pub mod info;
pub mod listen;
pub mod query;
Expand Down

0 comments on commit ef2a492

Please sign in to comment.