Add a `MsgpackTransport.pformat()`
And map `.__repr__/__str__` to it. Also adjust to new `Address.proto_key` and add a #TODO for a `.get_peers()`.ns_aware
parent
89993a4e3a
commit
46e775ce6d
|
@ -99,7 +99,7 @@ class MsgTransport(Protocol[MsgType]):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def key(cls) -> MsgTransportKey:
|
def key(cls) -> MsgTransportKey:
|
||||||
return cls.codec_key, cls.address_type.name_key
|
return cls.codec_key, cls.address_type.proto_key
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def laddr(self) -> Address:
|
def laddr(self) -> Address:
|
||||||
|
@ -136,6 +136,16 @@ class MsgTransport(Protocol[MsgType]):
|
||||||
'''
|
'''
|
||||||
...
|
...
|
||||||
|
|
||||||
|
# TODO, such that all `.raddr`s for each `SocketStream` are
|
||||||
|
# delivered?
|
||||||
|
# -[ ] move `.open_listener()` here and internally track the
|
||||||
|
# listener set, per address?
|
||||||
|
# def get_peers(
|
||||||
|
# self,
|
||||||
|
# ) -> list[Address]:
|
||||||
|
# ...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MsgpackTransport(MsgTransport):
|
class MsgpackTransport(MsgTransport):
|
||||||
|
|
||||||
|
@ -421,9 +431,12 @@ class MsgpackTransport(MsgTransport):
|
||||||
match trans_err:
|
match trans_err:
|
||||||
case trio.BrokenResourceError() if (
|
case trio.BrokenResourceError() if (
|
||||||
'[Errno 32] Broken pipe' in trans_err.args[0]
|
'[Errno 32] Broken pipe' in trans_err.args[0]
|
||||||
# ^XXX, specifc to UDS transport afaik?
|
# ^XXX, specifc to UDS transport and its,
|
||||||
# likely todo with races related to how fast
|
# well, "speediness".. XD
|
||||||
# the socket is setup/torn-down on linux..
|
# |_ likely todo with races related to how fast
|
||||||
|
# the socket is setup/torn-down on linux
|
||||||
|
# as it pertains to rando pings from the
|
||||||
|
# `.discovery` subsys and protos.
|
||||||
):
|
):
|
||||||
raise TransportClosed(
|
raise TransportClosed(
|
||||||
message=(
|
message=(
|
||||||
|
@ -438,6 +451,9 @@ class MsgpackTransport(MsgTransport):
|
||||||
# normal operation breakage" we usualy console warn
|
# normal operation breakage" we usualy console warn
|
||||||
# about it.
|
# about it.
|
||||||
case _:
|
case _:
|
||||||
|
log.exception(
|
||||||
|
'Transport layer failed for {self.transport!r} ?\n'
|
||||||
|
)
|
||||||
raise trans_err
|
raise trans_err
|
||||||
|
|
||||||
# ?TODO? does it help ever to dynamically show this
|
# ?TODO? does it help ever to dynamically show this
|
||||||
|
@ -477,3 +493,16 @@ class MsgpackTransport(MsgTransport):
|
||||||
@property
|
@property
|
||||||
def raddr(self) -> Address:
|
def raddr(self) -> Address:
|
||||||
return self._raddr
|
return self._raddr
|
||||||
|
|
||||||
|
def pformat(self) -> str:
|
||||||
|
return (
|
||||||
|
f'<{type(self).__name__}(\n'
|
||||||
|
f' |_task: {self._task}\n'
|
||||||
|
f'\n'
|
||||||
|
f' |_peers: 2\n'
|
||||||
|
f' laddr: {self._laddr}\n'
|
||||||
|
f' raddr: {self._raddr}\n'
|
||||||
|
f')>\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
__repr__ = __str__ = pformat
|
||||||
|
|
Loading…
Reference in New Issue