MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / get_client_session

Function get_client_session

crates/hyperqueue/src/server/bootstrap.rs:79–112  ·  view source on GitHub ↗
(server_directory: &Path)

Source from the content-addressed store, hash-verified

77}
78
79pub async fn get_client_session(server_directory: &Path) -> anyhow::Result<ClientSession> {
80 let default_home = default_server_directory();
81 let sd = ServerDir::open(server_directory).context("Invalid server directory")?;
82 let server_dir_msg = if default_home != server_directory {
83 format!(" --server-dir {}", server_directory.to_str().unwrap())
84 } else {
85 String::new()
86 };
87 let access_record_r = sd.read_client_access_record();
88
89 if let Err(HqError::VersionError(msg)) = access_record_r {
90 anyhow::bail!(msg);
91 }
92 let access_record = access_record_r.with_context(|| {
93 format!(
94 "No running instance of HQ found at {:?}.\n\
95 Try to start the server: `hq server start{}` or use a different server directory.",
96 sd.directory(),
97 server_dir_msg,
98 )
99 })?;
100
101 let session = ClientSession::connect_to_server(&access_record)
102 .await
103 .with_context(|| {
104 format!(
105 "Access token found but HQ server {}:{} is unreachable.\n\
106 Try to (re)start the server using `hq server start{}`",
107 access_record.client.host, access_record.client.port, server_dir_msg,
108 )
109 })?;
110
111 Ok(session)
112}
113
114async fn get_server_status(server_directory: &Path) -> crate::Result<ServerStatus> {
115 let record = ServerDir::open(server_directory).and_then(|sd| sd.read_client_access_record())?;

Callers 15

debug_dumpFunction · 0.85
stop_serverFunction · 0.85
print_server_infoFunction · 0.85
wait_for_serverFunction · 0.85
command_autoallocFunction · 0.85
stream_jsonFunction · 0.85
prune_journalFunction · 0.85
flush_journalFunction · 0.85
clientMethod · 0.85
preload_dashboard_eventsFunction · 0.85
command_job_submitFunction · 0.85
command_job_openFunction · 0.85

Calls 3

default_server_directoryFunction · 0.85
connect_to_serverFunction · 0.50

Tested by 1

clientMethod · 0.68