From c559f80f08d2067fc9400b47f2cf5b97efd8e404 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 22 Jun 2025 21:55:37 -0400 Subject: [PATCH] Extend `.msg.types.Aid` method interface Providing the legacy `.uid -> tuple` style id (since still used for the `Actor._contexts` table) and a `repr-one-line` method `.reprol() -> str` for rendering a compact unique actor ID summary (useful in logging/.pformat()s at the least). --- tractor/msg/types.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tractor/msg/types.py b/tractor/msg/types.py index aaf8d137..f077f132 100644 --- a/tractor/msg/types.py +++ b/tractor/msg/types.py @@ -154,6 +154,29 @@ class Aid( # should also include at least `.pid` (equiv to port for tcp) # and/or host-part always? + @property + def uid(self) -> tuple[str, str]: + ''' + Legacy actor "unique-id" pair format. + + ''' + return ( + self.name, + self.uuid, + ) + + def reprol( + self, + sin_uuid: bool = True, + ) -> str: + if not sin_uuid: + return ( + f'{self.name}[{self.uuid[:6]}]@{self.pid!r}' + ) + return ( + f'{self.name}@{self.pid!r}' + ) + class SpawnSpec( pretty_struct.Struct,