Operation Queue/Statistics sample #414
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes:
Adds a sample showing how to use the operation statistics support recently added to MQTT311 to implement an operation queue, controlling the flow of operations and ensuring that the MQTT311 connection cannot get too backed up. Additionally, it also allows finer control over the order of operations and the sending rate, as well as providing a way to have assurance that the MQTT311 connection cannot attempt to send too many operations (so long as the operation queue is used instead of the MQTT311 connection directly).
It also adds a test class that tests the operation queue to ensure it works as expected in all cases, as well as a detailed README explaining the sample. The sample and the sample operation queue tests are both run fully in CI.
Finally, it takes the samples in thesamples
folder and puts each sample in its own folder, along with its ownREADME
file instead of having one big file.This makes the samples easier to read without massive amounts of scrolling, as well as allowing us to add extra details where necessary without worry of bloating the markdown file other samples share.However, to share thecommand_line_utils.py
file properly, we have to perform a bit of an ugly hack/workaround that makes a soft-link to thecommand_line_utils.py
file at runtime. Not great, but I couldn't find a nice relative import solution and copying the file for each sample is sillyRelative imports didn't work either, even when both the sample and the command_line_utils.py where in their own modules. I couldn't get it working...Because the soft-link is made during runtime, it works fine on Windows thanks to Python3 soft-link support.The.gitignore
is set to ignore the softlink files in the samples.Edit: Splits the README down into per-sample README files into #415. This PR depends on that PR being merged first.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.