kopia lustrzana https://github.com/Yakifo/amqtt
pre 0.11.3 release cleanup (#294)
* add warning message for client config to match client config descriptionpull/276/head
rodzic
bfd2d86395
commit
b4df977f6f
20
README.md
20
README.md
|
@ -19,16 +19,16 @@
|
||||||
- Client auto-reconnection on network lost
|
- Client auto-reconnection on network lost
|
||||||
|
|
||||||
- Plugin framework for functionality expansion; included plugins:
|
- Plugin framework for functionality expansion; included plugins:
|
||||||
- `$SYS` topic publishing
|
- `$SYS` topic publishing
|
||||||
- AWS IOT-style shadow states
|
- AWS IOT-style shadow states
|
||||||
- x509 certificate authentication (including cli cert creation)
|
- x509 certificate authentication (including cli cert creation)
|
||||||
- Secure file-based password authentication
|
- Secure file-based password authentication
|
||||||
- Configuration-based topic authorization
|
- Configuration-based topic authorization
|
||||||
- MySQL, Postgres & SQLite user and/or topic auth (including cli manager)
|
- MySQL, Postgres & SQLite user and/or topic auth (including cli manager)
|
||||||
- External server (HTTP) user and/or topic auth
|
- External server (HTTP) user and/or topic auth
|
||||||
- LDAP user and/or topic auth
|
- LDAP user and/or topic auth
|
||||||
- JWT user and/or topic auth
|
- JWT user and/or topic auth
|
||||||
- Fail over session persistence
|
- Fail over session persistence
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
|
@ -577,7 +577,7 @@ class MQTTClient:
|
||||||
cadata: str | None = None,
|
cadata: str | None = None,
|
||||||
) -> Session:
|
) -> Session:
|
||||||
"""Initialize the MQTT session."""
|
"""Initialize the MQTT session."""
|
||||||
broker_conf = self.config.get("broker", {}).copy()
|
broker_conf = self.config.get("connection", {}).copy()
|
||||||
|
|
||||||
if uri is not None:
|
if uri is not None:
|
||||||
broker_conf.uri = uri
|
broker_conf.uri = uri
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from dataclasses import dataclass, field, fields, replace
|
from dataclasses import dataclass, field, fields, replace
|
||||||
import logging
|
import logging
|
||||||
|
import warnings
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from enum import Enum, StrEnum
|
from enum import Enum, StrEnum
|
||||||
|
@ -335,7 +336,7 @@ class ClientConfig(Dictable):
|
||||||
"""Upon reconnect, should subscriptions be cleared. Can be overridden by `MQTTClient.connect`"""
|
"""Upon reconnect, should subscriptions be cleared. Can be overridden by `MQTTClient.connect`"""
|
||||||
topics: dict[str, TopicConfig] | None = field(default_factory=dict)
|
topics: dict[str, TopicConfig] | None = field(default_factory=dict)
|
||||||
"""Specify the topics and what flags should be set for messages published to them."""
|
"""Specify the topics and what flags should be set for messages published to them."""
|
||||||
broker: ConnectionConfig | None = field(default_factory=ConnectionConfig)
|
broker: ConnectionConfig | None = None
|
||||||
"""*Deprecated* Configuration for connecting to the broker. Use `connection` field instead."""
|
"""*Deprecated* Configuration for connecting to the broker. Use `connection` field instead."""
|
||||||
connection: ConnectionConfig = field(default_factory=ConnectionConfig)
|
connection: ConnectionConfig = field(default_factory=ConnectionConfig)
|
||||||
"""Configuration for connecting to the broker. See
|
"""Configuration for connecting to the broker. See
|
||||||
|
@ -357,6 +358,7 @@ class ClientConfig(Dictable):
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
|
||||||
if self.broker is not None:
|
if self.broker is not None:
|
||||||
|
warnings.warn("The 'broker' option is deprecated, please use 'connection' instead.", stacklevel=2)
|
||||||
self.connection = self.broker
|
self.connection = self.broker
|
||||||
|
|
||||||
if bool(not self.connection.keyfile) ^ bool(not self.connection.certfile):
|
if bool(not self.connection.keyfile) ^ bool(not self.connection.certfile):
|
||||||
|
|
|
@ -132,7 +132,7 @@ class PluginManager(Generic[C]):
|
||||||
"Loading plugins from EntryPoints is deprecated and will be removed in a future version."
|
"Loading plugins from EntryPoints is deprecated and will be removed in a future version."
|
||||||
" Use `plugins` section of config instead.",
|
" Use `plugins` section of config instead.",
|
||||||
DeprecationWarning,
|
DeprecationWarning,
|
||||||
stacklevel=2
|
stacklevel=4
|
||||||
)
|
)
|
||||||
|
|
||||||
self._load_ep_plugins(namespace)
|
self._load_ep_plugins(namespace)
|
||||||
|
|
|
@ -7,7 +7,7 @@ auto_reconnect: true
|
||||||
cleansession: true
|
cleansession: true
|
||||||
reconnect_max_interval: 10
|
reconnect_max_interval: 10
|
||||||
reconnect_retries: 2
|
reconnect_retries: 2
|
||||||
broker:
|
connection:
|
||||||
uri: "mqtt://127.0.0.1"
|
uri: "mqtt://127.0.0.1"
|
||||||
plugins:
|
plugins:
|
||||||
amqtt.plugins.logging_amqtt.PacketLoggerPlugin:
|
amqtt.plugins.logging_amqtt.PacketLoggerPlugin:
|
||||||
|
|
|
@ -11,16 +11,16 @@
|
||||||
- Support QoS 0, QoS 1 and QoS 2 messages flow
|
- Support QoS 0, QoS 1 and QoS 2 messages flow
|
||||||
- Client auto-reconnection on network lost
|
- Client auto-reconnection on network lost
|
||||||
- Plugin framework for functionality expansion; included plugins:
|
- Plugin framework for functionality expansion; included plugins:
|
||||||
- `$SYS` topic publishing
|
- `$SYS` topic publishing
|
||||||
- AWS IOT-style shadow states
|
- AWS IOT-style shadow states
|
||||||
- x509 certificate authentication (including cli cert creation)
|
- x509 certificate authentication (including cli cert creation)
|
||||||
- Secure file-based password authentication
|
- Secure file-based password authentication
|
||||||
- Configuration-based topic authorization
|
- Configuration-based topic authorization
|
||||||
- MySQL, Postgres & SQLite user and/or topic auth (including cli manager)
|
- MySQL, Postgres & SQLite user and/or topic auth (including cli manager)
|
||||||
- External server (HTTP) user and/or topic auth
|
- External server (HTTP) user and/or topic auth
|
||||||
- LDAP user and/or topic auth
|
- LDAP user and/or topic auth
|
||||||
- JWT user and/or topic auth
|
- JWT user and/or topic auth
|
||||||
- Fail over session persistence
|
- Fail over session persistence
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|
|
@ -93,13 +93,14 @@ def mock_plugin_manager():
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def broker_fixture(test_config):
|
async def broker_fixture(test_config):
|
||||||
broker = Broker(test_config, plugin_namespace="amqtt.test.plugins")
|
with pytest.warns(DeprecationWarning):
|
||||||
await broker.start()
|
broker = Broker(test_config, plugin_namespace="amqtt.test.plugins")
|
||||||
assert broker.transitions.is_started()
|
await broker.start()
|
||||||
assert broker._sessions == {}
|
assert broker.transitions.is_started()
|
||||||
assert "default" in broker._servers
|
assert broker._sessions == {}
|
||||||
|
assert "default" in broker._servers
|
||||||
|
|
||||||
yield broker
|
yield broker
|
||||||
|
|
||||||
if not broker.transitions.is_stopped():
|
if not broker.transitions.is_stopped():
|
||||||
await broker.shutdown()
|
await broker.shutdown()
|
||||||
|
|
|
@ -256,7 +256,7 @@ def client_config():
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"keep_alive": 10,
|
"keep_alive": 10,
|
||||||
"broker": {
|
"connection": {
|
||||||
"uri": "mqtt://localhost:1884"
|
"uri": "mqtt://localhost:1884"
|
||||||
},
|
},
|
||||||
"reconnect_max_interval": 5,
|
"reconnect_max_interval": 5,
|
||||||
|
@ -489,13 +489,15 @@ async def test_client_no_auth():
|
||||||
|
|
||||||
client = MQTTClient(client_id="client1", config={'auto_reconnect': False})
|
client = MQTTClient(client_id="client1", config={'auto_reconnect': False})
|
||||||
|
|
||||||
broker = Broker(plugin_namespace='tests.mock_plugins', config=config)
|
with pytest.warns(DeprecationWarning):
|
||||||
await broker.start()
|
|
||||||
|
|
||||||
with pytest.raises(ConnectError):
|
broker = Broker(plugin_namespace='tests.mock_plugins', config=config)
|
||||||
await client.connect("mqtt://127.0.0.1:1883/")
|
await broker.start()
|
||||||
|
|
||||||
await broker.shutdown()
|
with pytest.raises(ConnectError):
|
||||||
|
await client.connect("mqtt://127.0.0.1:1883/")
|
||||||
|
|
||||||
|
await broker.shutdown()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
Ładowanie…
Reference in New Issue