mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 20:14:51 +00:00
Signed-off-by: wulan17 <wulan17@nusantararom.org> Co-authored-by: wulan17 <wulan17@nusantararom.org> Pyrofork: Use session name as database name, add some parameters informations and some cleanup (#3) Changes to be committed: modified: pyrogram/client.py modified: pyrogram/storage/mongo_storage.py Signed-off-by: wulan17 <wulan17@nusantararom.org> PyroFork: storage: mongo: Use existing database connection support both async_pymongo and motor Signed-off-by: wulan17 <wulan17@nusantararom.org> PyroFork: Use Dummy client object to check wether connection object is valid or not Signed-off-by: wulan17 <wulan17@nusantararom.org>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
from pymongo.client_session import TransactionOptions
|
|
from bson.codec_options import CodecOptions
|
|
from pymongo.read_concern import ReadConcern
|
|
from pymongo.read_preferences import (
|
|
Nearest,
|
|
Primary,
|
|
PrimaryPreferred,
|
|
Secondary,
|
|
SecondaryPreferred,
|
|
)
|
|
from pymongo.write_concern import WriteConcern
|
|
from typing import Any, Optional, Union
|
|
|
|
try:
|
|
from typing import Protocol, runtime_checkable
|
|
except ImportError:
|
|
from typing_extensions import Protocol, runtime_checkable
|
|
|
|
ReadPreferences = Union[Primary, PrimaryPreferred, Secondary, SecondaryPreferred, Nearest]
|
|
|
|
@runtime_checkable
|
|
class DummyMongoClient(Protocol):
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
raise NotImplementedError
|
|
|
|
def get_database(
|
|
self,
|
|
name: Optional[str] = None,
|
|
*,
|
|
codec_options: Optional[CodecOptions] = None,
|
|
read_preference: Optional[ReadPreferences] = None,
|
|
write_concern: Optional[WriteConcern] = None,
|
|
read_concern: Optional[ReadConcern] = None,
|
|
):
|
|
raise NotImplementedError
|
|
|
|
async def start_session(
|
|
self,
|
|
*,
|
|
causal_consistency: Optional[bool] = None,
|
|
default_transaction_options: Optional[TransactionOptions] = None,
|
|
snapshot: bool = False,
|
|
):
|
|
raise NotImplementedError
|