Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 724 Bytes

README.md

File metadata and controls

24 lines (16 loc) · 724 Bytes

Balancing http client around aiohttp

usage example:

import asyncio
from http_client import HttpClientFactory, AIOHttpClientWrapper
from http_client.balancing import RequestBalancerBuilder, Server, Upstream

async def runner():
    servers = [Server('127.0.0.1:9400', 10), Server('127.0.0.1:9401', 20)]
    request_balancer_builder = RequestBalancerBuilder({'backend1': Upstream('backend1', {}, servers)})
    http_client_factory = HttpClientFactory('app-name', AIOHttpClientWrapper(), request_balancer_builder)

    http_client = http_client_factory.get_http_client()

    result = await http_client.get_url('backend1', '/some_page')

    if not result.failed:
        print(result.data)


asyncio.run(runner())