Skip to content

Commit

Permalink
broker: Update syntax according to black recommendations.
Browse files Browse the repository at this point in the history
Following rebase.
  • Loading branch information
sjlongland committed Aug 17, 2021
1 parent e29d6a7 commit 6819ff6
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions amqtt/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class ListenerType(Enum):
Two types are supprted, TCP and WebSocket.
"""

TCP = "tcp"
WS = "ws"

Expand All @@ -133,17 +134,18 @@ class ListenerConfig(object):
"""
Configuration for a given listener.
"""

def __init__(
self,
type: Union[ListenerType, str],
bind: Optional[str] = None,
max_connections: int = -1,
ssl_active: Union[bool, str] = False,
cafile: Optional[str] = None,
capath: Optional[str] = None,
cadata: Optional[str] = None,
certfile: Optional[str] = None,
keyfile: Optional[str] = None,
self,
type: Union[ListenerType, str],
bind: Optional[str] = None,
max_connections: int = -1,
ssl_active: Union[bool, str] = False,
cafile: Optional[str] = None,
capath: Optional[str] = None,
cadata: Optional[str] = None,
certfile: Optional[str] = None,
keyfile: Optional[str] = None,
):
if isinstance(type, str):
type = ListenerType(type)
Expand Down Expand Up @@ -186,7 +188,7 @@ def __init__(
self.max_connections = max_connections

if isinstance(ssl_active, str):
ssl_active = (ssl_active.upper() == "ON")
ssl_active = ssl_active.upper() == "ON"

if ssl_active is True:
# certfile and keyfile are mandatory here
Expand Down Expand Up @@ -359,8 +361,7 @@ async def start(self) -> None:

if listener.port is None:
self.logger.debug(
"Listener configuration '%s' is not bound",
listener_name
"Listener configuration '%s' is not bound", listener_name
)
continue

Expand All @@ -377,10 +378,7 @@ async def start(self) -> None:
loop=self._loop,
)
self._servers[listener_name] = Server(
listener_name,
instance,
listener.max_connections,
self._loop
listener_name, instance, listener.max_connections, self._loop
)
elif listener.type == ListenerType.WS:
cb_partial = partial(self.ws_connected, listener_name=listener_name)
Expand All @@ -393,18 +391,15 @@ async def start(self) -> None:
subprotocols=["mqtt"],
)
self._servers[listener_name] = Server(
listener_name,
instance,
listener.max_connections,
self._loop
listener_name, instance, listener.max_connections, self._loop
)

self.logger.info(
"Listener '%s' bind to %s:%d (max_connections=%d)",
listener_name,
listener.address or 'any',
listener.address or "any",
listener.port,
listener.max_connections
listener.max_connections,
)

self.transitions.starting_success()
Expand Down

0 comments on commit 6819ff6

Please sign in to comment.