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