Class S3ClientFactory

java.lang.Object
com.kingsrook.qqq.backend.module.filesystem.s3.utils.S3ClientFactory

public class S3ClientFactory extends Object
Builds (and caches) AWS SDK v2 S3 clients from S3BackendMetaData. One client is kept per distinct set of connection settings, because SDK v2 clients own an HTTP connection pool and are meant to be long-lived and shared. The cache key is a SHA-256 hash of the settings, so no secret is held in a map key or a log line.
  • Field Details

    • DEFAULT_MAX_LISTED_OBJECTS

      public static final int DEFAULT_MAX_LISTED_OBJECTS
      See Also:
    • DEFAULT_CONNECT_TIMEOUT

      public static final Duration DEFAULT_CONNECT_TIMEOUT
    • DEFAULT_SOCKET_TIMEOUT

      public static final Duration DEFAULT_SOCKET_TIMEOUT
  • Method Details

    • getClient

      public static software.amazon.awssdk.services.s3.S3Client getClient(S3BackendMetaData backendMetaData)
      Get the shared client for a backend's connection settings, building it on first use. The client is shared: callers must not close it (use clearCache() to close all cached clients).
    • buildClient

      public static software.amazon.awssdk.services.s3.S3Client buildClient(S3BackendMetaData backendMetaData)
      Build a new (uncached) client. Callers own it, and should close it.
    • getEffectiveChecksumMode

      public static S3ChecksumMode getEffectiveChecksumMode(S3BackendMetaData backendMetaData)
      The checksum mode a backend actually uses: its explicit setting, else WHEN_REQUIRED for a custom endpoint (S3-compatible stores), else the SDK default, WHEN_SUPPORTED (AWS).
    • getEffectiveMaxListedObjects

      public static Integer getEffectiveMaxListedObjects(S3BackendMetaData backendMetaData)
      The listing cap a backend actually uses: null means the default; zero or negative means no cap (returned as null).
    • clearCache

      public static void clearCache()
      Close and forget every cached client (e.g., after credentials rotate, or between tests).