Skip to content

Roadmap 6/10: Background network loop, message queues, named connections #45

Description

@randomsync

Part of #39. Design: https://github.com/randomsync/robotframework-mqttlibrary/blob/master/design/MODERNIZATION.md (sections 1.3 and 4.1). Fixes #25, #28, #33. Carries forward ideas from PRs #27 and #23.

This is the phase that defines 1.0. After it, connections stay alive between keywords, no message is lost, and tests say which connection they mean.

Tasks

Connection object

  • _Connection owns the paho client, per-filter message queues, an unclaimed queue, and acknowledgement events by message id
  • A single on_message, installed before connecting, puts each message into every matching filter's queue, or into the unclaimed queue when none match
  • Registering a filter moves matching unclaimed messages into its queue. Registering an existing filter keeps its queue.
  • One lock per connection guards the filter registry, the unclaimed-queue drain and message dispatch

Keywords

  • Connect: keepalive= and alias= arguments, reconnect_on_failure=False, connect_timeout equal to the loop timeout, and loop_start(). Wait for CONNACK. On failure, stop the loop and raise with the broker's reason and the host.
  • Connecting again on a connected alias disconnects the old connection with a warning
  • Disconnect waits for the disconnect and stops the loop. Disconnect All and Switch Connection are new.
  • Publish waits for its own acknowledgement and raises with the paho error name on failure
  • Subscribe waits for its own SUBACK in both modes. Sync mode is shorthand for Subscribe followed by Listen.
  • Listen returns the oldest messages first and keeps the rest. It never resets the queue.
  • Unsubscribe waits for UNSUBACK and removes only its own filter
  • Subscribe And Validate uses the same queues and keeps its error text
  • Publish Single / Publish Multiple accept protocol as a name or a number
  • Remove every loop() call and every sleep() from the library

Tests

Acceptance criteria

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    roadmapModernization roadmap

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions