(&self)
| 608 | |
| 609 | impl 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 | |
| 657 | fn print_health(response: OwnerResponse, json: bool) -> CliResult<()> { |
nothing calls this directly
no test coverage detected