|
| 1 | +from proton._data import PropertyDict, symbol # noqa: E402 |
| 2 | +from proton._endpoints import Link # noqa: E402 |
| 3 | +from proton.reactor import LinkOption # noqa: E402 |
| 4 | + |
| 5 | + |
| 6 | +class SenderOption(LinkOption): |
| 7 | + def __init__(self, addr: str): |
| 8 | + self._addr = addr |
| 9 | + |
| 10 | + def apply(self, link: Link) -> None: |
| 11 | + link.source.address = self._addr |
| 12 | + link.snd_settle_mode = Link.SND_SETTLED |
| 13 | + link.rcv_settle_mode = Link.RCV_FIRST |
| 14 | + link.properties = PropertyDict({symbol("paired"): True}) |
| 15 | + link.source.dynamic = False |
| 16 | + |
| 17 | + def test(self, link: Link) -> bool: |
| 18 | + return bool(link.is_sender) |
| 19 | + |
| 20 | + |
| 21 | +class ReceiverOption(LinkOption): |
| 22 | + def __init__(self, addr: str): |
| 23 | + self._addr = addr |
| 24 | + |
| 25 | + def apply(self, link: Link) -> None: |
| 26 | + link.target.address = self._addr |
| 27 | + link.snd_settle_mode = Link.SND_SETTLED |
| 28 | + link.rcv_settle_mode = Link.RCV_FIRST |
| 29 | + link.properties = PropertyDict({symbol("paired"): True}) |
| 30 | + link.source.dynamic = False |
| 31 | + |
| 32 | + def test(self, link: Link) -> bool: |
| 33 | + return bool(link.is_receiver) |
0 commit comments