MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / token_slot

Function token_slot

crates/openshell-core/src/grpc_client.rs:211–234  ·  view source on GitHub ↗
(endpoint: &str, plain_channel: &Channel)

Source from the content-addressed store, hash-verified

209}
210
211async fn token_slot(endpoint: &str, plain_channel: &Channel) -> Result<(TokenSlot, RefreshMode)> {
212 if let Some(existing) = TOKEN_SLOT.get() {
213 let refresh_mode = TOKEN_REFRESH_MODE
214 .get()
215 .cloned()
216 .unwrap_or(RefreshMode::GatewayJwt(TokenSource::Env));
217 return Ok((existing.clone(), refresh_mode));
218 }
219
220 let _guard = TOKEN_INIT_LOCK.lock().await;
221
222 if let Some(existing) = TOKEN_SLOT.get() {
223 let refresh_mode = TOKEN_REFRESH_MODE
224 .get()
225 .cloned()
226 .unwrap_or(RefreshMode::GatewayJwt(TokenSource::Env));
227 return Ok((existing.clone(), refresh_mode));
228 }
229
230 let acquired = acquire_sandbox_token(endpoint, plain_channel).await?;
231 let slot = install_token_slot(&acquired.token)?;
232 let _ = TOKEN_REFRESH_MODE.set(acquired.refresh_mode.clone());
233 Ok((slot, acquired.refresh_mode))
234}
235
236/// Resolve the sandbox JWT used to authenticate every outbound RPC.
237///

Callers 1

connect_channelFunction · 0.85

Calls 4

acquire_sandbox_tokenFunction · 0.85
install_token_slotFunction · 0.85
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected