Class PhilterClient.PhilterClientBuilder
java.lang.Object
ai.philterd.philter.PhilterClient.PhilterClientBuilder
- Enclosing class:
PhilterClient
Builds
PhilterClient instances. Only withEndpoint(String) is required; all other
settings are optional and fall back to sensible defaults.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the configuredPhilterClient.withApiKey(String apiKey) Sets the value sent in theAuthorizationheader on every request.withEndpoint(String endpoint) Sets the base URL of the Philter instance, for examplehttps://localhost:8080.withKeepAliveDurationMs(int keepAliveDurationMs) Sets the connection keep-alive duration in milliseconds.withMaxIdleConnections(int maxIdleConnections) Sets the maximum number of idle connections in the connection pool.withOkHttpClientBuilder(okhttp3.OkHttpClient.Builder okHttpClientBuilder) Supplies a pre-configured OkHttp client builder.withTimeout(long timeout) Sets the connect, read, and write timeout in seconds.
-
Constructor Details
-
PhilterClientBuilder
public PhilterClientBuilder()
-
-
Method Details
-
withEndpoint
Sets the base URL of the Philter instance, for examplehttps://localhost:8080. Required.- Parameters:
endpoint- The Philter endpoint URL.- Returns:
- This builder.
-
withOkHttpClientBuilder
public PhilterClient.PhilterClientBuilder withOkHttpClientBuilder(okhttp3.OkHttpClient.Builder okHttpClientBuilder) Supplies a pre-configured OkHttp client builder. When provided, thetimeout,maxIdleConnections, andkeepAliveDurationMssettings are not applied and should be configured on the supplied builder instead. TheAuthorizationheader and any SSL configuration are still applied on top of it.- Parameters:
okHttpClientBuilder- The OkHttp client builder to use.- Returns:
- This builder.
-
withTimeout
Sets the connect, read, and write timeout in seconds. Defaults toPhilterClient.DEFAULT_TIMEOUT_SEC. Ignored when a client builder is supplied viawithOkHttpClientBuilder(OkHttpClient.Builder).- Parameters:
timeout- The timeout in seconds.- Returns:
- This builder.
-
withMaxIdleConnections
Sets the maximum number of idle connections in the connection pool. Defaults toPhilterClient.DEFAULT_MAX_IDLE_CONNECTIONS. Ignored when a client builder is supplied viawithOkHttpClientBuilder(OkHttpClient.Builder).- Parameters:
maxIdleConnections- The maximum number of idle connections.- Returns:
- This builder.
-
withKeepAliveDurationMs
Sets the connection keep-alive duration in milliseconds. Defaults toPhilterClient.DEFAULT_KEEP_ALIVE_DURATION_MS. Ignored when a client builder is supplied viawithOkHttpClientBuilder(OkHttpClient.Builder).- Parameters:
keepAliveDurationMs- The keep-alive duration in milliseconds.- Returns:
- This builder.
-
withApiKey
Sets the value sent in theAuthorizationheader on every request. The value is sent verbatim, so include any scheme prefix (for example"Bearer ") if your Philter deployment requires it.- Parameters:
apiKey- The Authorization header value.- Returns:
- This builder.
-
build
-