40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
# from typing import Iterable
|
|
#
|
|
# from funcy import rcompose
|
|
#
|
|
# from pyinfra.server.dispatcher.dispatchers.rest import RestDispatcher
|
|
# from pyinfra.server.interpreter.interpreters.identity import IdentityInterpreter
|
|
# from pyinfra.server.interpreter.interpreters.rest_callback import RestPickupStreamer
|
|
# from pyinfra.server.packer.packers.rest import RestPacker
|
|
# from pyinfra.server.client_pipeline import ClientPipeline
|
|
# from pyinfra.server.receiver.receivers.rest import RestReceiver
|
|
#
|
|
#
|
|
# def process_eagerly(endpoint, data: Iterable[bytes], metadata: Iterable[dict]):
|
|
# """Posts `data` to `url` and aggregates responses for each element of `data`."""
|
|
# pipeline = get_eager_pipeline(endpoint)
|
|
# yield from pipeline(data, metadata)
|
|
#
|
|
#
|
|
# def process_lazily(endpoint, data: Iterable[bytes], metadata: Iterable[dict]):
|
|
# """Posts `data` to `url` and aggregates responses for each element of `data` by querying a pickup endpoint.
|
|
#
|
|
# Requires:
|
|
# - responses must provide return pickup_endpoint as JSON payload
|
|
# - responses must have status code 206 for more responses coming and 204 for the last response already sent
|
|
# """
|
|
# pipeline = get_lazy_pipeline(endpoint)
|
|
# yield from pipeline(data, metadata)
|
|
#
|
|
#
|
|
# def get_eager_pipeline(endpoint):
|
|
# return ClientPipeline(*pipeline_head(endpoint), IdentityInterpreter())
|
|
#
|
|
#
|
|
# def get_lazy_pipeline(endpoint):
|
|
# return ClientPipeline(*pipeline_head(endpoint), rcompose(RestPickupStreamer(), RestReceiver()))
|
|
#
|
|
#
|
|
# def pipeline_head(url):
|
|
# return RestPacker(), RestDispatcher(url), RestReceiver()
|