Class BaseDifyServerToken
java.lang.Object
io.github.guoshiqiufeng.dify.server.client.BaseDifyServerToken
- Direct Known Subclasses:
DifyServerTokenDefault,DifyServerTokenRedis
- Since:
- 2025/4/9 13:28
- Version:
- 1.0
- Author:
- yanghq
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddAuthorizationHeader(org.springframework.http.HttpHeaders headers, DifyServerClient difyServerClient) Abstract method to add authorization header to HTTP request.<T> TexecuteWithRetry(RequestSupplier<T> supplier, DifyServerClient difyServerClient) Executes the given request supplier with automatic retry mechanism.
-
Field Details
-
MAX_RETRY_ATTEMPTS
protected static final int MAX_RETRY_ATTEMPTS最大重试次数- See Also:
-
-
Constructor Details
-
BaseDifyServerToken
public BaseDifyServerToken()
-
-
Method Details
-
addAuthorizationHeader
public abstract void addAuthorizationHeader(org.springframework.http.HttpHeaders headers, DifyServerClient difyServerClient) Abstract method to add authorization header to HTTP request.- Parameters:
headers- HTTP headers to be populated with authorization informationdifyServerClient- client instance containing necessary configuration
-
executeWithRetry
Executes the given request supplier with automatic retry mechanism. Will retry when encountering 401 Unauthorized errors, up to MAX_RETRY_ATTEMPTS times.- Type Parameters:
T- type of the response object- Parameters:
supplier- request execution supplier that provides the resultdifyServerClient- client instance for token refresh operations- Returns:
- result from the successful request execution
- Throws:
RuntimeException- when max retry attempts are exhaustedException- when non-retryable errors occur
-