Skip to content

Commit

Permalink
refactor: SilverbackIdent -> SilverbackID
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeshultz committed Nov 29, 2023
1 parent 4f0b11b commit 5bf000c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions silverback/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from taskiq import TaskiqMessage, TaskiqMiddleware, TaskiqResult

from silverback.persistence import HandlerResult
from silverback.types import SilverbackIdent, handler_id_block, handler_id_event
from silverback.types import SilverbackID, handler_id_block, handler_id_event
from silverback.utils import hexbytes_dict


Expand Down Expand Up @@ -40,7 +40,7 @@ def compute_block_time() -> int:
settings = kwargs.pop("silverback_settings")

self.block_time = self.chain_manager.provider.network.block_time or compute_block_time()
self.ident = SilverbackIdent.from_settings(settings)
self.ident = SilverbackID.from_settings(settings)
self.persistence = settings.get_persistent_store()

def pre_send(self, message: TaskiqMessage) -> TaskiqMessage:
Expand Down
16 changes: 8 additions & 8 deletions silverback/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from taskiq import TaskiqResult
from typing_extensions import Self # Introduced 3.11

from .types import SilverbackIdent
from .types import SilverbackID

_HandlerReturnType = TypeVar("_HandlerReturnType")

Expand All @@ -35,7 +35,7 @@ class HandlerResult(TaskiqResult):
@classmethod
def from_taskiq(
cls,
ident: SilverbackIdent,
ident: SilverbackID,
handler_id: str,
block_number: Optional[int],
log_index: Optional[int],
Expand All @@ -59,20 +59,20 @@ async def init(self):
...

@abstractmethod
async def get_state(self, ident: SilverbackIdent) -> Optional[SilverbackState]:
async def get_state(self, ident: SilverbackID) -> Optional[SilverbackState]:
"""Return the stored state for a Silverback instance"""
...

@abstractmethod
async def set_state(
self, ident: SilverbackIdent, last_block_seen: int, last_block_processed: int
self, ident: SilverbackID, last_block_seen: int, last_block_processed: int
) -> Optional[SilverbackState]:
"""Set the stored state for a Silverback instance"""
...

@abstractmethod
async def get_latest_result(
self, ident: SilverbackIdent, handler: Optional[str] = None
self, ident: SilverbackID, handler: Optional[str] = None
) -> Optional[HandlerResult]:
"""Return the latest result for a Silverback instance's handler"""
...
Expand Down Expand Up @@ -182,7 +182,7 @@ async def init(self):

self.initialized = True

async def get_state(self, ident: SilverbackIdent) -> Optional[SilverbackState]:
async def get_state(self, ident: SilverbackID) -> Optional[SilverbackState]:
if not self.initialized:
await self.init()

Expand All @@ -209,7 +209,7 @@ async def get_state(self, ident: SilverbackIdent) -> Optional[SilverbackState]:
)

async def set_state(
self, ident: SilverbackIdent, last_block_seen: int, last_block_processed: int
self, ident: SilverbackID, last_block_seen: int, last_block_processed: int
) -> Optional[SilverbackState]:
if not self.initialized:
await self.init()
Expand Down Expand Up @@ -261,7 +261,7 @@ async def set_state(
)

async def get_latest_result(
self, ident: SilverbackIdent, handler: Optional[str] = None
self, ident: SilverbackID, handler: Optional[str] = None
) -> Optional[HandlerResult]:
if not self.initialized:
await self.init()
Expand Down
4 changes: 2 additions & 2 deletions silverback/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .persistence import BasePersistentStore
from .settings import Settings
from .subscriptions import SubscriptionType, Web3SubscriptionsManager
from .types import SilverbackIdent, SilverbackStartupState
from .types import SilverbackID, SilverbackStartupState
from .utils import async_wrap_iter, hexbytes_dict

settings = Settings()
Expand All @@ -29,7 +29,7 @@ def __init__(self, app: SilverbackApp, *args, max_exceptions: int = 3, **kwargs)
self.last_block_seen = 0
self.last_block_processed = 0
self.persistence: Optional[BasePersistentStore] = None
self.ident = SilverbackIdent.from_settings(settings)
self.ident = SilverbackID.from_settings(settings)

def _handle_result(self, result: TaskiqResult):
if result.is_err:
Expand Down
2 changes: 1 addition & 1 deletion silverback/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def get_network_choice(self) -> str:
...


class SilverbackIdent(BaseModel):
class SilverbackID(BaseModel):
identifier: str
network_choice: str

Expand Down

0 comments on commit 5bf000c

Please sign in to comment.