Remove channel registry#1371
Open
simonvoelcker wants to merge 5 commits intofrequenz-floss:v1.x.xfrom
Open
Conversation
f4e6125 to
9186ad8
Compare
360ca1a to
a878b7a
Compare
…ChannelRegistry Signed-off-by: Simon Völcker <simon.voelcker@frequenz.com>
Signed-off-by: Simon Völcker <simon.voelcker@frequenz.com>
Signed-off-by: Simon Völcker <simon.voelcker@frequenz.com>
Signed-off-by: Simon Völcker <simon.voelcker@frequenz.com>
Signed-off-by: Simon Völcker <simon.voelcker@frequenz.com>
a878b7a to
22cd7c5
Compare
simonvoelcker
commented
Mar 6, 2026
| "frequenz-microgrid-component-graph >= 0.3.4, < 0.4", | ||
| "frequenz-client-common >= 0.3.6, < 0.4.0", | ||
| "frequenz-channels >= 1.6.1, < 2.0.0", | ||
| "frequenz-channels @ git+https://github.com/shsms/frequenz-channels-python.git@oneshot", |
Contributor
Author
There was a problem hiding this comment.
I won't merge before this is merged 👀
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This removes the
ChannelRegistryclass.Background
This is part of an initiative to close unused channels to save resources. The
ChannelRegistrywas a de-facto singleton class for storing channels by name. Request objects such asComponentMetricRequestorReportRequesthave aget_channel_name()method, and the returned channel name acted as a contract between sender and receiver - With the name, they could obtain the same channel from theChannelRegistry. By getting rid of the registry, we are moving towards a target state where only references to senders and receivers, but no channels are being held.Implementation
ComponentMetricRequest
ComponentMetricRequestobjects represent a request to receive metrics from a component - Sometimes also referred to as telemetry stream. To serve such a request without relying on theChannelRegistry, the request got a new attribute:telem_stream_sender: Sender[Receiver[Sample[Quantity]]]. This is the sender of a one-shot channel that is used to send the receiver of the telemetry stream back to the original requester - Similar to a callback function. The receiver of a component metric request should therefore create (and own) the channel that sends the metric data, and use the one-shot channel to send a receiver of that channel "back".In a few places, component metric requests were created and sent from synchronous functions which returned the receiver. To make this work with the round-trip outlined above, an additional channel was added that merely forwards the metric data via a
Pipe. This allows us to immediately return a sender while the channel that serves the metric data is being constructed asynchronously.These changes can be found in the first commit.
ReportRequest
ReportRequestobjects are a different kind of request that was handled similarly.These changes can be found in the second commit.
Channel ownership
The receivers of request objects create the channels and own them. For instance, in case of
ComponentMetricRequests, MicrogridApiSource now maintains a dictionary (channel_lookup: dict[str, Broadcast]) as a replacement for the channel registry. It is necessary to have this lookup dictionary to avoid creating duplicate channels for similar metric requests. In this case, a new receiver is created from an existing channel found in the lookup dictionary.Forwarding channels are owned by their creator (e.g.
GridFrequency). These (and the Pipes that connect them to the other channels) are currently never closed. Closing these when all receivers or senders are closed is a TODO for a later iteration.