Class SandboxConnector
java.lang.Object
io.agentscope.extensions.sandbox.kubernetes.client.internal.SandboxConnector
Manages HTTP connectivity to the sandbox (via router or in-cluster),
including URL discovery, retry logic, and header injection.
-
Constructor Summary
ConstructorsConstructorDescriptionSandboxConnector(String sandboxId, String namespace, SandboxConnectionConfig connectionConfig, K8sHelper k8sHelper, Supplier<String> podIpSupplier) SandboxConnector(String sandboxId, String namespace, SandboxConnectionConfig connectionConfig, K8sHelper k8sHelper, Supplier<String> podIpSupplier, Duration requestTimeout, Duration perAttemptTimeout) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Tears down the transport.voidconnect()Discovers the base URL via the connection strategy.booleansendRequest(String method, String endpoint, HttpRequest.BodyPublisher body, String contentType, int maxRetries) Sends an HTTP request with retry logic and optional sandbox headers.HttpResponse<byte[]>sendRequestForBytes(String method, String endpoint, HttpRequest.BodyPublisher body, String contentType) Sends a request and returns the raw byte response (for file downloads).
-
Constructor Details
-
SandboxConnector
-
SandboxConnector
-
-
Method Details
-
connect
Discovers the base URL via the connection strategy.- Throws:
Exception- if discovery fails
-
close
public void close()Tears down the transport. -
isConnected
public boolean isConnected() -
getStrategy
-
sendRequest
public HttpResponse<String> sendRequest(String method, String endpoint, HttpRequest.BodyPublisher body, String contentType, int maxRetries) throws IOException, InterruptedException Sends an HTTP request with retry logic and optional sandbox headers.- Parameters:
method- HTTP methodendpoint- path relative to base URLbody- request body, or null for GETcontentType- content type headermaxRetries- max attempts (0 = default)- Returns:
- HTTP response
- Throws:
IOExceptionInterruptedException
-
sendRequestForBytes
public HttpResponse<byte[]> sendRequestForBytes(String method, String endpoint, HttpRequest.BodyPublisher body, String contentType) throws IOException, InterruptedException Sends a request and returns the raw byte response (for file downloads).- Parameters:
method- HTTP methodendpoint- pathbody- body or nullcontentType- content type- Returns:
- byte response
- Throws:
IOExceptionInterruptedException
-