Skip to content

Commit 64840ea

Browse files
authored
Merge pull request #354 from shmel1k/bugfix/topictypes_consumers_missprint
[topic] fix missprint for topictypes
2 parents 8abc51f + d040b90 commit 64840ea

File tree

7 files changed

+108
-9
lines changed

7 files changed

+108
-9
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

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Added more fields to `DescribeTopicResult` from `TopicService`
2+
13
## v3.34.2
24
* Added some description to error message from table pool get
35
* Moved implementation `sugar.GenerateDeclareSection` to `internal/table`

internal/grpcwrapper/rawtopic/describe_topic.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package rawtopic
22

33
import (
44
"fmt"
5+
"time"
56

67
"github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Topic"
78
"google.golang.org/protobuf/proto"
89

910
"github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawscheme"
11+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawtopic/rawtopiccommon"
1012
"github.com/ydb-platform/ydb-go-sdk/v3/internal/grpcwrapper/rawydb"
1113
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
1214
)
@@ -26,9 +28,14 @@ func (req *DescribeTopicRequest) ToProto() *Ydb_Topic.DescribeTopicRequest {
2628
type DescribeTopicResult struct {
2729
Operation rawydb.Operation
2830

29-
Self rawscheme.Entry
30-
PartitioningSettings PartitioningSettings
31-
Consumers []Consumer
31+
Self rawscheme.Entry
32+
PartitioningSettings PartitioningSettings
33+
Consumers []Consumer
34+
SupportedCodecs rawtopiccommon.SupportedCodecs
35+
RetentionPeriod time.Duration
36+
PartitionWriteBurstBytes int64
37+
PartitionWriteSpeedBytesPerSecond int64
38+
Attributes map[string]string
3239
}
3340

3441
func (res *DescribeTopicResult) FromProto(protoResponse *Ydb_Topic.DescribeTopicResponse) error {
@@ -49,6 +56,24 @@ func (res *DescribeTopicResult) FromProto(protoResponse *Ydb_Topic.DescribeTopic
4956
return err
5057
}
5158

59+
res.PartitionWriteBurstBytes = protoResult.PartitionWriteBurstBytes
60+
res.PartitionWriteSpeedBytesPerSecond = protoResult.PartitionWriteSpeedBytesPerSecond
61+
62+
if protoResult.RetentionPeriod != nil {
63+
res.RetentionPeriod = protoResult.RetentionPeriod.AsDuration()
64+
}
65+
66+
if protoResult.SupportedCodecs != nil {
67+
for _, v := range protoResult.SupportedCodecs.Codecs {
68+
res.SupportedCodecs = append(res.SupportedCodecs, rawtopiccommon.Codec(v))
69+
}
70+
}
71+
72+
res.Attributes = make(map[string]string)
73+
for k, v := range protoResult.Attributes {
74+
res.Attributes[k] = v
75+
}
76+
5277
res.Consumers = make([]Consumer, len(protoResult.Consumers))
5378
for i := range res.Consumers {
5479
res.Consumers[i].MustFromProto(protoResult.Consumers[i])

topic/client_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
"github.com/stretchr/testify/require"
1313

14-
"github.com/ydb-platform/ydb-go-sdk/v3"
14+
ydb "github.com/ydb-platform/ydb-go-sdk/v3"
1515
"github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptions"
1616
"github.com/ydb-platform/ydb-go-sdk/v3/topic/topictypes"
1717
)

topic/example_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"io/ioutil"
77

8-
"github.com/ydb-platform/ydb-go-sdk/v3"
8+
ydb "github.com/ydb-platform/ydb-go-sdk/v3"
99
"github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptions"
1010
)
1111

topic/reader_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
"github.com/stretchr/testify/require"
1616

17-
"github.com/ydb-platform/ydb-go-sdk/v3"
17+
ydb "github.com/ydb-platform/ydb-go-sdk/v3"
1818
"github.com/ydb-platform/ydb-go-sdk/v3/internal/empty"
1919
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xcontext"
2020
"github.com/ydb-platform/ydb-go-sdk/v3/internal/xtest"

topic/topictypes/topictypes.go

Lines changed: 74 additions & 3 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(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.
97117
type 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 {
108133
func (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

Comments
 (0)