from minio import Minio
from queue import Queue
from urllib.parse import urlparse

class MinioClientPool:
    def __init__(self, endpoint, access_key, secret_key, pool_size=5):
        self.pool = Queue(maxsize=pool_size)
        self.endpoint = endpoint
        for _ in range(pool_size):
            client = Minio(endpoint, access_key=access_key, secret_key=secret_key, secure=False)
            self.pool.put(client)

    def get_client(self) -> Minio:
        return self.pool.get()

    def release_client(self, client):
        self.pool.put(client)

    def get_ip_address(self):
        return self.endpoint