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

Experimental: allow custom prefetch_count on trigger policies #749

Open
wants to merge 4 commits into
base: release-1.1
Choose a base branch
from

Conversation

Annopaolo
Copy link
Collaborator

@Annopaolo Annopaolo commented Jan 12, 2023

When using Trigger Delivery Policies, ordered event delivery is not guaranteed because messages might not be dequeued (thus processed) sequentially. Allow the policy to specify the AMQP consumer prefetch count used for its event queue. If the value is 1, the Trigger Engine instance processes events sequentially.
This is an experimental feature and thus disabled by default. You can enable it with the REALM_MANAGEMENT_ALLOW_AMQP_CONSUMER_PREFETCH_COUNT env var. Note that, even if the flag is enabled, the default policy will still respect the default prefetch count, so as not to break compatibility with previous Astarte versions.

@Annopaolo
Copy link
Collaborator Author

Based on astarte-platform/astarte_core#83.

@Annopaolo Annopaolo changed the title TriggerEngine: allow custom prefetch_count on trigger policies Experimental: allow custom prefetch_count on trigger policies Jan 20, 2023
@Annopaolo Annopaolo added enhancement New feature or request performance This issue or pull request is about performances (e.g. bottlenecks, optimizations) user experience This issue is about user experience app:realm_management This issue or pull request is about astarte_realm_management application app:trigger_engine This issue or pull request is about astarte_trigger_engine application labels Jan 20, 2023
@codecov
Copy link

codecov bot commented Mar 6, 2023

Codecov Report

Merging #749 (487ab80) into release-1.1 (b89afbb) will increase coverage by 0.32%.
The diff coverage is 80.76%.

❗ Current head 487ab80 differs from pull request most recent head 6d7ab9d. Consider uploading reports for the commit 6d7ab9d to get more accurate results

@@               Coverage Diff               @@
##           release-1.1     #749      +/-   ##
===============================================
+ Coverage        68.43%   68.75%   +0.32%     
===============================================
  Files              258      259       +1     
  Lines             5911     5924      +13     
===============================================
+ Hits              4045     4073      +28     
+ Misses            1866     1851      -15     
Impacted Files Coverage Δ
...tarte_realm_management_api/triggers/amqp_action.ex 55.55% <ø> (+55.55%) ⬆️
...tarte_realm_management_api/triggers/http_action.ex 83.33% <ø> (-2.39%) ⬇️
...agement_api_web/controllers/fallback_controller.ex 33.33% <0.00%> (-2.39%) ⬇️
...tarte_realm_management_api_web/views/error_view.ex 53.84% <0.00%> (-4.49%) ⬇️
...gger_engine/amqp_consumer/amqp_consumer_tracker.ex 100.00% <ø> (ø)
...gger_engine/amqp_consumer/amqp_message_consumer.ex 65.45% <66.66%> (-0.59%) ⬇️
...b/astarte_realm_management_api/triggers/trigger.ex 78.94% <77.77%> (+71.80%) ⬆️
..._management/lib/astarte_realm_management/config.ex 66.66% <100.00%> (+4.16%) ⬆️
..._management/lib/astarte_realm_management/engine.ex 82.85% <100.00%> (+0.28%) ⬆️
...ib/astarte_realm_management_api/triggers/action.ex 100.00% <100.00%> (ø)
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Annopaolo Annopaolo marked this pull request as ready for review March 6, 2023 11:13
When using Trigger Delivery Policies, ordered event delivery is not guaranteed
because messages might not be dequeued (thus processed) sequentially.
As a possible solution, allow the policy to specify the AMQP consumer prefetch
count used for its event queue. If the value is 1, an instance of Trigger Engine
processes events sequentially.
This is an experimental feature and thus disabled by default. You can enable it
with the `REALM_MANAGEMENT_ALLOW_TRIGGER_POLICY_PREFETCH_COUNT` env var.

Signed-off-by: Arnaldo Cesco <arnaldo.cesco@secomind.com>
Signed-off-by: Arnaldo Cesco <arnaldo.cesco@secomind.com>
Until now, a trigger policy used a consumer prefetch set by the
`TRIGGER_ENGINE_AMQP_CONSUMER_PREFETCH_COUNT` env (as usual in Astarte).
If the policy provides a custom consumer prefetch count (e.g. for message
ordering reasons), use that prefetch value. This can be done if the related
Realm Management flag is enabled.
The default policy will still respect the default prefetch count, so as not
to break compatibility with previous Astarte versions.

Signed-off-by: Arnaldo Cesco <arnaldo.cesco@secomind.com>
Signed-off-by: Arnaldo Cesco <arnaldo.cesco@secomind.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:realm_management This issue or pull request is about astarte_realm_management application app:trigger_engine This issue or pull request is about astarte_trigger_engine application enhancement New feature or request performance This issue or pull request is about performances (e.g. bottlenecks, optimizations) user experience This issue is about user experience
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

1 participant