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

Use event-based mechanism for stream discovery #14130

Merged
merged 11 commits into from
Nov 4, 2024

Conversation

ieQu1
Copy link
Member

@ieQu1 ieQu1 commented Nov 1, 2024

Fixes

Release version: v/e5.?

Summary

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • Added tests for the changes
  • Added property-based tests for code which performs user input validation
  • Changed lines covered in coverage report
  • Change log has been added to changes/(ce|ee)/(feat|perf|fix|breaking)-<PR-id>.en.md files
  • For internal contributor: there is a jira ticket to track this change
  • Created PR to emqx-docs if documentation update is required, or link to a follow-up jira ticket
  • Schema changes are backward compatible

Checklist for CI (.github/workflows) changes

  • If changed package build workflow, pass this action (manual trigger)
  • Change log has been added to changes/ dir for user-facing artifacts update

@ieQu1 ieQu1 force-pushed the dev/new-stream-events branch 2 times, most recently from 3a468d2 to 91685aa Compare November 2, 2024 12:48
@ieQu1 ieQu1 changed the title New stream events Use event-based mechanism for stream discovery Nov 2, 2024
@ieQu1 ieQu1 force-pushed the dev/new-stream-events branch 3 times, most recently from 1194284 to bcbeb9f Compare November 2, 2024 17:46
@ieQu1 ieQu1 force-pushed the dev/new-stream-events branch from bcbeb9f to 8a7d56b Compare November 2, 2024 18:44
@ieQu1 ieQu1 marked this pull request as ready for review November 3, 2024 13:48
@ieQu1 ieQu1 requested review from keynslug, a team and lafirest as code owners November 3, 2024 13:48
savonarola
savonarola previously approved these changes Nov 4, 2024
%% all nodes.
-spec notify_new_stream(emqx_ds:db(), emqx_ds:topic_filter()) -> ok.
notify_new_stream(DB, TF) ->
emqx_ds_new_streams_proto_v1:notify([node() | nodes()], DB, TF).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need running_nodes here?

Copy link
Member Author

@ieQu1 ieQu1 Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, yes. But I don't like the kludge of using mria:running_nodes() for unintended purpose.

It's mostly used as a workaround to avoid sending rpc calls to nodes that can't handle them (e.g. rshell), it's less relevant for casts, since reply is not expected.

%% "active" flag. Whenever it receives a notification about a new
%% stream, it matches all active subscriptions' topic-filters against
%% the topic-filter of the event, and sets `active' flags for every
%% match.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably some explantion of "dirty" therminology is needed.


register_db(DB, Backend) ->
ets:insert(?TAB, {DB, Backend}),
_ = supervisor:start_child(?WATCH_SUP, [DB]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this supervisor stopped on db close/drop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's never stopped by design. Stopping it would lose subscriptions and all events. I'll add a comment.


%% @doc This module is used for notifying processes about new streams.
%% It's not a replacement for `emqx_ds:get_streams' function, it's
%% only meant to optimize its usage.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relation of the API that this module provides to the DS API may be still unclear: is it available for all DS'es? Which DS'es should implement it? How is it possible for a DS consumer understand whether it is possible to use it?

Copy link
Member Author

@ieQu1 ieQu1 Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the idea is that any DS backend/layout can use this module at its own discretion. I didn't have time to design a fancy layered API.

@ieQu1 ieQu1 dismissed stale reviews from savonarola and thalesmg via ee9f89b November 4, 2024 17:20
@ieQu1 ieQu1 requested review from thalesmg and savonarola November 4, 2024 18:06
@ieQu1 ieQu1 merged commit d3864d0 into emqx:release-58 Nov 4, 2024
199 checks passed
@emqxqa
Copy link

emqxqa commented Nov 5, 2024

TestExecution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants