Package com.vaadin.copilot
Class CopilotServerClient
java.lang.Object
com.vaadin.copilot.CopilotServerClient
- Direct Known Subclasses:
AnalyticsClient,FeedbackClient,TestGenerationServerClient,UserInfoServerClient
Base class for Copilot Server API clients
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic enum -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildRequest(URI uri, Object request) static BooleanReturns the Copilot server reachability state.getQueryURI(String path) protected static Stringprotected static voidprotected static voidRecords a failed request unless the server has already been reached in this application run.static StringreportRequestFailure(org.slf4j.Logger logger, String context, Throwable error) Logs a failed Copilot server request and returns a user-facing error message.<REQ,RESP>
voidsendCopilotRequest(String path, REQ request, Class<RESP> responseType, Consumer<RESP> responseHandler, com.vaadin.base.devserver.DevToolsInterface devToolsInterface, String command, tools.jackson.databind.JsonNode respData) <REQ,RESP>
voidsendCopilotRequest(String path, REQ request, Class<RESP> responseType, Consumer<RESP> responseHandler, Consumer<Throwable> errorHandler) voidsendFireAndForget(String path, Object request) Sends a best-effort, fire-and-forget POST request to the Copilot server.
-
Field Details
-
SERVER_URL_ENV
- See Also:
-
-
Constructor Details
-
CopilotServerClient
public CopilotServerClient()Constructor initializing HttpClient and ObjectMapper
-
-
Method Details
-
getHttpClient
-
buildRequest
-
getQueryURI
-
getServerBaseUrl
-
sendCopilotRequest
-
reportRequestFailure
Logs a failed Copilot server request and returns a user-facing error message. A proxy authentication failure is logged atWARNwith a clear explanation and returned as-is; any other error is logged atERRORwith its stack trace and yields a generic message. Centralizes failure reporting so every (synchronous) caller behaves consistently.- Parameters:
logger- the caller's loggercontext- a short description of what failed, used for the error-level logerror- the error that was thrown- Returns:
- a message suitable for showing to the user
-
sendCopilotRequest
-
sendFireAndForget
Sends a best-effort, fire-and-forget POST request to the Copilot server.The caller never observes the result, and a failure must never affect the calling thread. It reuses the shared
HttpClient(rather than a reactor-netty client, whose eager HTTP/3 SSL init can fail with aLinkageErroron hosts that pin a conflicting Netty version) and swallows request failures so best-effort traffic stays isolated.- Parameters:
path- server path to POST torequest- payload serialized to JSON
-
getCopilotServerReachability
Returns the Copilot server reachability state.nullmeans no request has been attempted,falsemeans an attempt failed, andtruemeans a response was received. -
markCopilotServerReached
protected static void markCopilotServerReached() -
markCopilotServerUnreachable
protected static void markCopilotServerUnreachable()Records a failed request unless the server has already been reached in this application run. -
resolveAiProvider
-