mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-14 08:49:44 +00:00
improve the Listener protocol somewhat
This commit is contained in:
parent
cbfbfe8b1e
commit
ed237b0dba
@ -6,11 +6,13 @@ detect when it is possible to use it, etc.
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Protocol
|
from typing import Any, Awaitable, Protocol, Sequence, Mapping, Optional
|
||||||
|
from typing_extensions import Literal
|
||||||
|
|
||||||
from attrs import frozen
|
from attrs import frozen, define
|
||||||
|
|
||||||
from .interfaces import IAddressFamily
|
from .interfaces import IAddressFamily
|
||||||
|
from .util.iputil import allocate_tcp_port
|
||||||
|
|
||||||
@frozen
|
@frozen
|
||||||
class ListenerConfig:
|
class ListenerConfig:
|
||||||
@ -19,14 +21,12 @@ class ListenerConfig:
|
|||||||
|
|
||||||
:ivar tub_locations: Entries to merge into ``[node]tub.location``.
|
:ivar tub_locations: Entries to merge into ``[node]tub.location``.
|
||||||
|
|
||||||
:ivar node_config: Entries to merge into the overall Tahoe-LAFS
|
:ivar node_config: Entries to add into the overall Tahoe-LAFS
|
||||||
configuration. XXX Note: Sections currently merge by overwriting
|
configuration beneath a section named after this listener.
|
||||||
existing items with overlapping keys. In the future it would be nice
|
|
||||||
to merge every item sensibly (or error).
|
|
||||||
"""
|
"""
|
||||||
tub_ports: list[str]
|
tub_ports: Sequence[str]
|
||||||
tub_locations: list[str]
|
tub_locations: Sequence[str]
|
||||||
node_config: dict[str, dict[str, str]]
|
node_config: Mapping[str, Sequence[tuple[str, str]]]
|
||||||
|
|
||||||
class Listener(Protocol):
|
class Listener(Protocol):
|
||||||
"""
|
"""
|
||||||
@ -45,7 +45,7 @@ class Listener(Protocol):
|
|||||||
node's public internet address from peers?
|
node's public internet address from peers?
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def create_config(self, reactor: Any, cli_config: Any) -> ListenerConfig:
|
async def create_config(self, reactor: Any, cli_config: Any) -> Optional[ListenerConfig]:
|
||||||
"""
|
"""
|
||||||
Set up an instance of this listener according to the given
|
Set up an instance of this listener according to the given
|
||||||
configuration parameters.
|
configuration parameters.
|
||||||
@ -56,7 +56,7 @@ class Listener(Protocol):
|
|||||||
overall *tahoe.cfg* configuration file.
|
overall *tahoe.cfg* configuration file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def create(self, config: Any, reactor: Any) -> IAddressFamily:
|
def create(self, reactor: Any, config: Any) -> IAddressFamily:
|
||||||
"""
|
"""
|
||||||
Instantiate this listener according to the given
|
Instantiate this listener according to the given
|
||||||
previously-generated configuration.
|
previously-generated configuration.
|
||||||
|
Loading…
Reference in New Issue
Block a user