Skip to content

Commit 0a6b474

Browse files
committed
[topic] add consumers to topicdescription
1 parent 59a5fee commit 0a6b474

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
.history/
66
.devcontainer
77
*.vsix
8+
*.swp
89

910

1011
*.exe

topic/topictypes/topictypes.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
75+
}
76+
77+
if !raw.ReadFrom.IsZero() {
78+
c.ReadFrom = raw.ReadFrom.Value
79+
}
80+
}
81+
6282
// PartitionSettings
6383
//
6484
// # Experimental
@@ -108,4 +128,9 @@ type TopicDescription struct {
108128
func (d *TopicDescription) FromRaw(raw *rawtopic.DescribeTopicResult) {
109129
d.Path = raw.Self.Name
110130
d.PartitionSettings.FromRaw(&raw.PartitioningSettings)
131+
132+
d.Consumers = make([]Consumer, len(raw.Consumers))
133+
for i := 0; i < raw.Consumers; i++ {
134+
d.Consumers[i].FromRaw(&raw.Consumers[i])
135+
}
111136
}

0 commit comments

Comments
 (0)