
    (^i                    .   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ erd dlZd d	lmZ d d
lmZ n ed      Z ed      Z ed      Z ej(                  e      ZdZ	 d	 	 	 	 	 	 	 	 	 ddZ e	d      dddd	 	 	 	 	 	 	 	 	 dd       Zy)    )annotations)ThreadPoolExecutor)TYPE_CHECKING)logging)experimental_func)_LazyImport)BaseStorageN)servicer)api_pb2_grpcgrpczoptuna.storages._grpc.servicerz1optuna.storages._grpc.auto_generated.api_pb2_grpcz%Y-%m-%d %H:%M:%S.%fc                    t        j                  |xs t        d            }t        j                  t        j                  |       |       |j                  | d|        |S )N
   )max_workers:)r   serverr   r   $add_StorageServiceServicer_to_servergrpc_servicerOptunaStorageProxyServiceadd_insecure_portstoragehostportthread_poolr   s        ]/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/optuna/storages/_grpc/server.pymake_serverr      s[     [[J(:r(JKF55//8& vQtf-.M    z4.2.0	localhosti2  )r   r   r   c                   t        | |||      }|j                          t        j                  d| d|        t        j                  d       |j	                          y)a  Run a gRPC server for the given storage URL, host, and port.

    Example:

        Run this server with the following way:

        .. code::

            from optuna.storages import run_grpc_proxy_server
            from optuna.storages import get_storage

            storage = get_storage("mysql+pymysql://<user>:<pass>@<host>/<dbname>[?<options>]")
            run_grpc_proxy_server(storage, host="localhost", port=13000)

        Please refer to the client class :class:`~optuna.storages.GrpcStorageProxy` for
        the client usage. Please use :func:`~optuna.storages.get_storage` instead of
        :class:`~optuna.storages.RDBStorage` since ``RDBStorage`` by itself does not use cache in
        process and it may cause significant slowdown.

    Args:
        storage: A storage object to proxy.
        host: Hostname to listen on.
        port: Port to listen on.
        thread_pool:
            Thread pool to use for the server. If :obj:`None`, a default thread pool
            with 10 workers will be used.

    .. warning::

        Currently, gRPC storage proxy does not support the
        :class:`~optuna.storages.JournalStorage`. This issue is tracked in
        https://github.com/optuna/optuna/issues/6084. Please use
        :class:`~optuna.storages.RDBStorage` instead.
    zServer started at r   zListening...N)r   start_loggerinfowait_for_terminationr   s        r   run_grpc_proxy_serverr$   &   sP    T $k:F
LLNLL%dV1TF34LL 
!r   )N)
r   r	   r   strr   intr   ThreadPoolExecutor | Nonereturnzgrpc.Server)
r   r	   r   r%   r   r&   r   r'   r(   None)
__future__r   concurrent.futuresr   typingr   optunar   optuna._experimentalr   optuna._importsr   optuna.storagesr	   r   optuna.storages._grpcr
   r   $optuna.storages._grpc.auto_generatedr   
get_logger__name__r!   DATETIME_FORMATr   r$    r   r   <module>r7      s    " 1    2 ' ' ?AvD @AMRSL '

X
&( Z^ #+.=V 7 -1-"-" -" 	-"
 +-" 
-" -"r   