Set consistency

    Order:

    1. consistency request
    2. "stale" / "consistent" parameters
    3. ctx consistency

def consistency_middleware(ctx, get_response):
    """Set consistency

    Order:

    1. consistency request
    2. "stale" / "consistent" parameters
    3. ctx consistency
    """
    async def middleware(request):
        params = request.setdefault("params", {})
        consistency = request.pop("consistency", None)
        a, b = set_consistency(consistency, ctx.consistency, params)
        params["consistent"] = a
        params["stale"] = b
        return await get_response(request)
    return middleware