• Julien PRIGENT's avatar
    [HaClient] Asyncua ha client (#367) · f874f7db
    Julien PRIGENT authored
    * [HaClient] Asyncua client wrapper
    
    It exposes an interface similar to Client. You'll find some examples
    and tests to guide you through this new feature.
    
    Under the hood, it starts a keepalive task to monitor the status and
    service level for each server.
    
    It also includes an HaManager task which promotes a primary and
    reconnect unhealthy clients. Unhealthy clients are detected based
    on the socket status and keepalive data collected.
    
    The requests received by users as well as the HaManager decisions
    produce an ideal state called the "ideal_map". Regularly, the reconciliator task
    kicks in, lock this configuration, and applies the "ideal_map" configuration.
    It then stores the actual subscriptions status into the "real_map" using the
    lower level components of the library.
    
    Current limits:
    
    - We only support HA WARM mode and datachange notifications (no event/status_change).
    _ We support multiple subscriptions, but a node should only be subscribed once.
    
    Component details:
    
    - HaClient:
        - Configuration based on dataclasses: HaConfig (required) and HaConfigSecurity (optional)
        - Responsible to start up sides tasks: keepalive, hamanager, reconciliator
        - Mutates the ideal_map via VirtualSubscription
        - Generic hooks (i.e: to monitor subscription performance)
    
    - KeepAlive (task):
        - Regularly hits the server to check its service_level / status.
    
    - HaManager (task):
        - Promote primary / secondaries
        - Reconnect disconnected/unhealthy client based on the keepalive
        feedback.
    
    - Reconciliator (task):
        - Applies the ideal configuration
        - Perform checks on the call responses
        - Mutates the real_map
    
    - VirtualSubscription:
        - Key component of the ideal and real maps.
        - Exposes an interface similar to the subscription but only
        store the settings.
    
    * [HaClient] fix test for py3.8/py3.9
    
    CancelledError and TimeoutError have moved from concurrent.futures to
    asyncio. Note that CancelledError now inherits from BaseException and
    not Exception anymore. See https://bugs.python.org/issue32528
    
     for the
    details.
    Finally, fix pytest_yield_fixture deprecation
    
    * [HaClient] address the comments (utils + refacto reconciliator)
    Co-authored-by: default avataroroulet <oroulet@users.noreply.github.com>
    f874f7db
setup.py 1.81 KB