@@ -59,7 +59,21 @@ def __init__(
59
59
auto_create_topics = auto_create_topics ,
60
60
)
61
61
self ._quix_config_builder = quix_config_builder
62
- self ._topic_id_to_name : dict [str , str ] = {}
62
+
63
+ def stream_id_from_topics (self , * topics : Topic ) -> str :
64
+ """
65
+ Generate a stream_id by combining names of the provided topics.
66
+ """
67
+ if not topics :
68
+ raise ValueError ("At least one Topic must be passed" )
69
+ elif len (topics ) == 1 :
70
+ # If only one topic is passed, return its full name
71
+ # for backwards compatibility
72
+ return topics [0 ].name
73
+
74
+ # Use the "quix_name" to generate stream_id.
75
+ # In Quix Cloud, the "quix_name" can differ from the actual broker topic name
76
+ return "--" .join (t .quix_name for t in topics )
63
77
64
78
def _fetch_topic (self , topic : Topic ) -> Topic :
65
79
try :
@@ -92,10 +106,6 @@ def _finalize_topic(self, topic: Topic) -> Topic:
92
106
broker_topic = self ._fetch_topic (topic = topic )
93
107
broker_config = broker_topic .broker_config
94
108
95
- # A hack to pass extra info back from Quix cloud
96
- quix_topic_name = broker_config .extra_config .pop ("__quix_topic_name__" )
97
- topic_out = topic .__clone__ (name = broker_topic .name )
98
-
99
109
# Set a broker config for the topic
100
110
broker_config = TopicConfig (
101
111
num_partitions = broker_config .num_partitions ,
@@ -106,8 +116,8 @@ def _finalize_topic(self, topic: Topic) -> Topic:
106
116
if k in self ._extra_config_imports
107
117
},
108
118
)
119
+ topic_out = topic .__clone__ (name = broker_topic .name )
109
120
topic_out .broker_config = broker_config
110
- self ._topic_id_to_name [topic_out .name ] = quix_topic_name
111
121
self ._quix_config_builder .wait_for_topic_ready_statuses ([topic_out ])
112
122
return topic_out
113
123
@@ -148,8 +158,13 @@ def _internal_name(
148
158
149
159
:return: formatted topic name
150
160
"""
151
- return super ()._internal_name (
152
- topic_type ,
153
- self ._topic_id_to_name [topic_name ] if topic_name else None ,
154
- suffix ,
155
- )
161
+
162
+ # Map the full topic name to the shorter "quix_name" and use
163
+ # it for internal topics.
164
+ # "quix_name" is not prefixed with the workspace id.
165
+ if topic_name is not None :
166
+ topic = self .non_changelog_topics .get (topic_name )
167
+ if topic is not None :
168
+ topic_name = topic .quix_name
169
+
170
+ return super ()._internal_name (topic_type , topic_name , suffix )
0 commit comments