@@ -59,6 +59,26 @@ func (c *Consumer) ToRaw(raw *rawtopic.Consumer) {
5959 raw .Attributes = c .Attributes
6060}
6161
62+ // FromRaw
63+ //
64+ // # Experimental
65+ //
66+ // Notice: This API is EXPERIMENTAL and may be changed or removed in a later release.
67+ func (c * Consumer ) FromRaw (raw * rawtopic.Consumer ) {
68+ c .Attributes = raw .Attributes
69+ c .Important = raw .Important
70+ c .Name = raw .Name
71+
72+ c .SupportedCodecs = make ([]Codec , len (raw .SupportedCodecs ))
73+ for index , codec := range raw .SupportedCodecs {
74+ c .SupportedCodecs [index ] = Codec (codec )
75+ }
76+
77+ if raw .ReadFrom .HasValue {
78+ c .ReadFrom = raw .ReadFrom .Value
79+ }
80+ }
81+
6282// PartitionSettings
6383//
6484// # Experimental
@@ -95,9 +115,14 @@ func (s *PartitionSettings) FromRaw(raw *rawtopic.PartitioningSettings) {
95115//
96116// Notice: This API is EXPERIMENTAL and may be changed or removed in a later release.
97117type TopicDescription struct {
98- Path string
99- PartitionSettings PartitionSettings
100- Consmers []Consumer
118+ Path string
119+ PartitionSettings PartitionSettings
120+ Consumers []Consumer
121+ SupportedCodecs []Codec
122+ RetentionPeriod time.Duration
123+ PartitionWriteBurstBytes int64
124+ PartitionWriteSpeedBytesPerSecond int64
125+ Attributes map [string ]string
101126}
102127
103128// FromRaw
@@ -108,4 +133,50 @@ type TopicDescription struct {
108133func (d * TopicDescription ) FromRaw (raw * rawtopic.DescribeTopicResult ) {
109134 d .Path = raw .Self .Name
110135 d .PartitionSettings .FromRaw (& raw .PartitioningSettings )
136+
137+ d .Consumers = make ([]Consumer , len (raw .Consumers ))
138+ for i := 0 ; i < len (raw .Consumers ); i ++ {
139+ d .Consumers [i ].FromRaw (& raw .Consumers [i ])
140+ }
141+
142+ d .SupportedCodecs = make ([]Codec , len (raw .SupportedCodecs ))
143+ for i := 0 ; i < len (raw .SupportedCodecs ); i ++ {
144+ d .SupportedCodecs [i ] = Codec (raw .SupportedCodecs [i ])
145+ }
146+
147+ d .PartitionWriteSpeedBytesPerSecond = raw .PartitionWriteSpeedBytesPerSecond
148+ d .PartitionWriteBurstBytes = raw .PartitionWriteBurstBytes
149+
150+ d .Attributes = make (map [string ]string )
151+ for k , v := range raw .Attributes {
152+ d .Attributes [k ] = v
153+ }
154+ }
155+
156+ // ToRaw
157+ //
158+ // # Experimental
159+ //
160+ // Notice: This API is EXPERIMENTAL and may be changed or removed in a later release.
161+ func (d * TopicDescription ) ToRaw (raw * rawtopic.DescribeTopicResult ) {
162+ raw .Self .Name = d .Path
163+ d .PartitionSettings .ToRaw (& raw .PartitioningSettings )
164+
165+ raw .Consumers = make ([]rawtopic.Consumer , len (d .Consumers ))
166+ for i := 0 ; i < len (d .Consumers ); i ++ {
167+ d .Consumers [i ].ToRaw (& raw .Consumers [i ])
168+ }
169+
170+ raw .SupportedCodecs = make ([]rawtopiccommon.Codec , len (d .SupportedCodecs ))
171+ for i := 0 ; i < len (d .SupportedCodecs ); i ++ {
172+ raw .SupportedCodecs [i ] = rawtopiccommon .Codec (d .SupportedCodecs [i ])
173+ }
174+
175+ raw .PartitionWriteBurstBytes = d .PartitionWriteBurstBytes
176+ raw .PartitionWriteSpeedBytesPerSecond = d .PartitionWriteSpeedBytesPerSecond
177+
178+ raw .Attributes = make (map [string ]string )
179+ for k , v := range d .Attributes {
180+ raw .Attributes [k ] = v
181+ }
111182}
0 commit comments