Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for aio-mqtt 2.0 #6

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace: kubealex

name: eda

version: 1.0.7
version: 1.0.8

readme: README.md

Expand Down
15 changes: 6 additions & 9 deletions plugins/event_source/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,17 @@ async def main(queue: asyncio.Queue, args: Dict[str, Any]) -> None:
password=password,
tls_params=tls_params if ca_certs else None,
)

await mqtt_consumer.connect()

try:
async with mqtt_consumer.messages() as messages:
async with mqtt_consumer:
try:
await mqtt_consumer.subscribe(topic)
async for message in messages:
async for message in mqtt_consumer.messages:
try:
data = json.loads(message.payload.decode())
await queue.put(data)
except json.decoder.JSONDecodeError:
logger.exception("Decoding exception for incoming message")
finally:
logger.info("Disconneccting from broker")
mqtt_consumer.disconnect()
finally:
logger.info("Disconneccting from broker")


if __name__ == "__main__":
Expand All @@ -96,3 +92,4 @@ async def put(self: "MockQueue", event: dict) -> None:
{"topic": "eda", "host": "localhost", "port": "1883"},
),
)