code: def consistency_middleware(ctx, get_response):
      
      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
docs: Set consistency
  
      Order:
  
      1. consistency request
      2. "stale" / "consistent" parameters
      3. ctx consistency