MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / run

Method run

atomic-cli/src/commands/agent/owner.rs:610–654  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

608
609impl Command for DatabaseOwner {
610 fn run(&self) -> CliResult<()> {
611 match &self.command {
612 OwnerCommand::Start(args) => {
613 let response = start_or_reconnect(&args.repository)?;
614 print_health(response, args.json)
615 }
616 OwnerCommand::Ping(args) => {
617 let response = request(&args.repository, OwnerRequest::Ping)?;
618 print_health(response, args.json)
619 }
620 OwnerCommand::Reserve(args) => {
621 start_or_reconnect(&args.repository)?;
622 let response = request(
623 &args.repository,
624 OwnerRequest::ReserveProvenanceTurn {
625 session_id: args.session_id.clone(),
626 turn_number: args.turn,
627 now: args.now,
628 },
629 )?;
630 print_reservation(response, args.json)
631 }
632 OwnerCommand::Shutdown(args) => {
633 let response = request(&args.repository, OwnerRequest::Shutdown)?;
634 let pid = match response {
635 OwnerResponse::ShuttingDown { pid } => pid,
636 other => return Err(unexpected_response("shutdown", other).into()),
637 };
638 if args.json {
639 println!(
640 "{}",
641 serde_json::json!({
642 "protocol_version": PROTOCOL_VERSION,
643 "pid": pid,
644 "status": "shutting-down"
645 })
646 );
647 } else {
648 println!("database owner {pid} is shutting down");
649 }
650 Ok(())
651 }
652 OwnerCommand::Serve(args) => serve(&args.repository),
653 }
654 }
655}
656
657fn print_health(response: OwnerResponse, json: bool) -> CliResult<()> {

Callers

nothing calls this directly

Calls 7

start_or_reconnectFunction · 0.85
print_healthFunction · 0.85
print_reservationFunction · 0.85
unexpected_responseFunction · 0.85
serveFunction · 0.85
requestFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected