This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt::Debug; | |
use bytes::Bytes; | |
use lz4_flex; | |
use pingora::{Error, Result}; | |
/// Content types that skip cache compression by default | |
pub const SKIP_COMPRESSION: &'static [&'static str] = &[ | |
"image/avif", | |
"image/webp", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Download tiles from tile sever "smart way" - fetchin for biggest zoom and then going down only if tile has some data | |
""" | |
from __future__ import annotations | |
import asyncio | |
import io | |
from itertools import batched | |
import math |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use async_trait::async_trait; | |
use hickory_resolver::TokioAsyncResolver; | |
use http::Extensions; | |
use pingora::lb::discovery::ServiceDiscovery; | |
use pingora::lb::selection::{BackendIter, BackendSelection}; | |
use pingora::lb::{Backend, Backends, LoadBalancer}; | |
use pingora::protocols::l4::socket::SocketAddr; | |
use pingora::{Error, ErrorSource, ErrorType, Result as PingoraResult}; | |
use std::fmt::Debug; | |
use std::net::{IpAddr, SocketAddrV4}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import strawberry | |
def filter_unset_input(input): | |
result = {} | |
for key in input.__annotations__.keys(): | |
value = getattr(input, key) | |
if value != strawberry.arguments.UNSET: | |
result[key] = value | |
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Generic, TypeVar | |
import strawberry | |
from django.core.paginator import EmptyPage, Page, PageNotAnInteger, Paginator | |
from django.db.models.query import QuerySet | |
T = TypeVar("T") | |
MAX_PAGE_SIZE = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from asyncio import Semaphore | |
from io import DEFAULT_BUFFER_SIZE | |
from os import PathLike | |
import aiofiles | |
import aiohttp | |
from zipstream import AioZipStream | |
async def download_files_into_zip( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from typing import Generic, List, Optional, TypeVar | |
from fastapi import Query | |
from pydantic.generics import GenericModel | |
from starlette.datastructures import URL | |
DEFAULT_PAGE_SIZE = 25 | |
MAX_PAGE_SIZE = 100 |