added redis adapter
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
from .connection_aware_interface import ConnectionAwareInterface as ConnectionAwareInterface
|
||||
from .context_aware_interface import ContextAwareInterface as ContextAwareInterface
|
||||
|
||||
__all__ = [
|
||||
"ConnectionAwareInterface",
|
||||
"ContextAwareInterface",
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
"""Definition of ConnectionAwareInterface abstract base class."""
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class ConnectionAwareInterface(ABC):
|
||||
"""Interface that defines connection-related methods."""
|
||||
|
||||
@abstractmethod
|
||||
def connect(self) -> None:
|
||||
"""Connect to resource."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abstractmethod
|
||||
def disconnect(self) -> None:
|
||||
"""Disconnect from resource."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def is_connected(self) -> bool:
|
||||
"""Check if connected to resource."""
|
||||
raise NotImplementedError()
|
||||
@@ -0,0 +1,24 @@
|
||||
"""Definition of ConnectionAwareInterface abstract base class."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class ContextAwareInterface(ABC):
|
||||
"""Interface that defined context-related methods."""
|
||||
|
||||
@abstractmethod
|
||||
def __enter__(self) -> ContextAwareInterface:
|
||||
"""Enter the context."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abstractmethod
|
||||
def __exit__(
|
||||
self,
|
||||
exc_type: type | None,
|
||||
exc_val: object | None,
|
||||
exc_tb: object | None
|
||||
) -> None:
|
||||
"""Exit the context."""
|
||||
raise NotImplementedError()
|
||||
Reference in New Issue
Block a user