1313
1414@dataclass
1515class ComponentMetricRequest :
16- """A request object to start streaming a metric for a component."""
16+ """A request to start streaming a component's metric.
17+
18+ Requesters use this class to specify which component's metric they want to subscribe
19+ to, including the component ID, metric ID, and an optional start time. The
20+ `namespace` is defined by the requester and influences the construction of the
21+ channel name via the `get_channel_name()` method.
22+
23+ The `namespace` allows differentiation of data streams for the same component and
24+ metric. For example, requesters can use different `namespace` values to subscribe to
25+ raw or resampled data streams separately. This ensures that each requester receives
26+ the appropriate type of data without interference. Requests with the same
27+ `namespace`, `component_id`, and `metric_id` will use the same channel, preventing
28+ unnecessary duplication of data streams.
29+
30+ The requester and provider must use the same channel name so that they can
31+ independently retrieve the same channel from the `ChannelRegistry`. This is
32+ achieved by using the `get_channel_name` method to generate the name on both sides
33+ based on parameters set by the requesters.
34+ """
1735
1836 namespace : str
19- """The namespace that this request belongs to.
20-
21- Metric requests with a shared namespace enable the reuse of channels within
22- that namespace.
23-
24- If for example, an actor making a multiple requests, uses the name of the
25- actor as the namespace, then requests from the actor will get reused when
26- possible.
27- """
37+ """A client-defined identifier influencing the channel name."""
2838
2939 component_id : int
3040 """The ID of the requested component."""
@@ -35,17 +45,14 @@ class ComponentMetricRequest:
3545 start_time : datetime | None
3646 """The start time from which data is required.
3747
38- When None, we will stream only live data.
48+ If None, only live data is streamed .
3949 """
4050
4151 def get_channel_name (self ) -> str :
42- """Return a channel name constructed from Self.
43-
44- This channel name can be used by the sending side and receiving sides to
45- identify the right channel from the ChannelRegistry.
52+ """Construct the channel name based on the request parameters.
4653
4754 Returns:
48- A string denoting a channel name.
55+ A string representing the channel name.
4956 """
5057 return (
5158 f"component_metric_request<namespace={ self .namespace } ,"
0 commit comments