Skip to content

relay: add PublisherCrossExecFilter and SubscriberCrossExecFilter#329

Merged
afrind merged 1 commit into
mainfrom
pr329
May 25, 2026
Merged

relay: add PublisherCrossExecFilter and SubscriberCrossExecFilter#329
afrind merged 1 commit into
mainfrom
pr329

Conversation

@afrind
Copy link
Copy Markdown
Contributor

@afrind afrind commented May 25, 2026

Summary:
Adds two executor-crossing filter classes that wrap the Publisher and
Subscriber interfaces and forward all calls to a target executor.

PublisherCrossExecFilter uses co_withExecutor on every coroutine method
(subscribe, fetch, trackStatus, subscribeNamespace) to switch to the
target executor before invoking the inner. goaway() is fire-and-forget
via executor->add().

SubscriberCrossExecFilter does the same for publishNamespace() and
goaway(). publish() is more involved: it returns a CrossExecFilter as
the consumer immediately (before the inner is called), then the reply
Task switches to the target executor, calls inner->publish(), and wires
setDownstream() to connect the real consumer. FIFO ordering on the
target executor guarantees setDownstream() runs before any data writes
enqueued afterward.

Both classes require the target executor to be FIFO if call ordering
matters. Unit tests cover success/error paths for all methods plus the
goaway enqueue-vs-invoke ordering.

Test Plan:
moqx_publisher_cross_exec_filter_test
moqx_subscriber_cross_exec_filter_test


This change is Reviewable

Copy link
Copy Markdown
Contributor

@gmarzot gmarzot left a comment

Choose a reason for hiding this comment

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

@gmarzot reviewed 8 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on akash-a-n, michalhosna, mondain, Oxyd, peterchave, suhasHere, and TimEvens).

Base automatically changed from pr328 to main May 25, 2026 17:02
@afrind afrind force-pushed the pr329 branch 2 times, most recently from 791816b to c80d25c Compare May 25, 2026 18:03
Summary:
Adds two executor-crossing filter classes that wrap the Publisher and
Subscriber interfaces and forward all calls to a target executor.

PublisherCrossExecFilter uses co_withExecutor on every coroutine method
(subscribe, fetch, trackStatus, subscribeNamespace) to switch to the
target executor before invoking the inner. goaway() is fire-and-forget
via executor->add().

SubscriberCrossExecFilter does the same for publishNamespace() and
goaway(). publish() is more involved: it returns a CrossExecFilter as
the consumer immediately (before the inner is called), then the reply
Task switches to the target executor, calls inner->publish(), and wires
setDownstream() to connect the real consumer. FIFO ordering on the
target executor guarantees setDownstream() runs before any data writes
enqueued afterward.

Both classes require the target executor to be FIFO if call ordering
matters. Unit tests cover success/error paths for all methods plus the
goaway enqueue-vs-invoke ordering.

Test Plan:
moqx_publisher_cross_exec_filter_test
moqx_subscriber_cross_exec_filter_test
@afrind afrind merged commit d3599cb into main May 25, 2026
15 of 20 checks passed
@afrind afrind deleted the pr329 branch May 25, 2026 20:02
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.

2 participants