Skip to content

Latest commit

 

History

History
56 lines (43 loc) · 1.68 KB

File metadata and controls

56 lines (43 loc) · 1.68 KB

Configuration

Back to README

Every injection point is a static property on ConnectionPoolConfiguration. Set them at app startup, before any other ConnectionPool API is used.

Contents

Injecting a Custom Logger

struct MyLogger: ConnectionPoolLogger {
    func log(
        _ message: String,
        level: PoolLogLevel,
        category: PoolLogCategory,
        file: String,
        function: String,
        line: Int
    ) {
        print("[\(level.rawValue)] [\(category.rawValue)] \(message)")
    }
}

// Set before using any ConnectionPool APIs
ConnectionPoolConfiguration.logger = MyLogger()

Injecting Encrypted Block List Storage

struct SecureStorage: BlockListStorageProvider {
    func save(_ data: Data, forKey key: String) throws {
        // Write to Keychain or encrypted file
    }
    func load(forKey key: String) throws -> Data? {
        // Read from Keychain or encrypted file
    }
}

// Set at app startup
ConnectionPoolConfiguration.blockListStorageProvider = SecureStorage()

Injecting Encrypted Remote Pool State Storage

// Same protocol as block list storage, so reuse your SecureStorage implementation
ConnectionPoolConfiguration.remotePoolStateStorageProvider = SecureStorage()

When set, RemotePoolState persists through this provider instead of plain UserDefaults, preventing connection history (server URL, pool ID, host status) from being stored unencrypted.