Skip to content

Commit 662fa3e

Browse files
authored
* Changed type of topic/topicoptions.AlterOption from func to inter… (#413)
* * Changed type of `topic/topicoptions.AlterOption` from func to interface * Changed type of `topic/topicoptions.CreateOption` from func to interface * Added implementations of `topic/topicoptions.AlterOption` and `topic/topicoptions.CreateOption` * add sorting of slice entities * * Changed type of `topic/topicoptions.DescribeOption` from func to interface * Changed type of `topic/topicoptions.DropOption` from func to interface * renames * * Changed type of `table/options.{Create,Alter,Drop}TableOption` from func to interface * Added implementations of `table/options.{Create,Alter,Drop}Option` * revert topicoptions.DescribeOption type
1 parent d4731e4 commit 662fa3e

File tree

10 files changed

+728
-312
lines changed

10 files changed

+728
-312
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Changed type of `table/options.{Create,Alter,Drop}TableOption` from func to interface
2+
* Added implementations of `table/options.{Create,Alter,Drop}Option`
3+
* Changed type of `topic/topicoptions.{Create,Alter,Drop}Option` from func to interface
4+
* Added implementations of `topic/topicoptions.{Create,Alter}Option`
15
* Fix internal race-condition bugs in internal background worker
26

37
## v3.38.3

internal/table/session.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (s *session) CreateTable(
273273
)
274274
defer a.Free()
275275
for _, opt := range opts {
276-
opt((*options.CreateTableDesc)(&request), a)
276+
opt.ApplyCreateTableOption((*options.CreateTableDesc)(&request), a)
277277
}
278278
t := s.trailer()
279279
defer t.processHints()
@@ -449,7 +449,7 @@ func (s *session) DropTable(
449449
),
450450
}
451451
for _, opt := range opts {
452-
opt((*options.DropTableDesc)(&request))
452+
opt.ApplyDropTableOption((*options.DropTableDesc)(&request))
453453
}
454454
t := s.trailer()
455455
defer t.processHints()
@@ -491,7 +491,7 @@ func (s *session) AlterTable(
491491
)
492492
defer a.Free()
493493
for _, opt := range opts {
494-
opt((*options.AlterTableDesc)(&request), a)
494+
opt.ApplyAlterTableOption((*options.AlterTableDesc)(&request), a)
495495
}
496496
t := s.trailer()
497497
defer t.processHints()

internal/topic/topicclientinternal/client.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func (c *Client) Alter(ctx context.Context, path string, opts ...topicoptions.Al
6868
req := rawtopic.AlterTopicRequest{}
6969
req.OperationParams = c.defaultOperationParams
7070
req.Path = path
71-
for _, f := range opts {
72-
f(&req)
71+
for _, o := range opts {
72+
o.ApplyAlterOption(&req)
7373
}
7474

7575
call := func(ctx context.Context) error {
@@ -97,8 +97,8 @@ func (c *Client) Create(
9797
req.OperationParams = c.defaultOperationParams
9898
req.Path = path
9999

100-
for _, f := range opts {
101-
f(&req)
100+
for _, o := range opts {
101+
o.ApplyCreateOption(&req)
102102
}
103103

104104
call := func(ctx context.Context) error {
@@ -127,8 +127,8 @@ func (c *Client) Describe(
127127
Path: path,
128128
}
129129

130-
for _, opt := range opts {
131-
opt(&req)
130+
for _, o := range opts {
131+
o(&req)
132132
}
133133

134134
var rawRes rawtopic.DescribeTopicResult
@@ -164,8 +164,8 @@ func (c *Client) Drop(ctx context.Context, path string, opts ...topicoptions.Dro
164164
req.OperationParams = c.defaultOperationParams
165165
req.Path = path
166166

167-
for _, f := range opts {
168-
f(&req)
167+
for _, o := range opts {
168+
o.ApplyDropOption(&req)
169169
}
170170

171171
call := func(ctx context.Context) error {

0 commit comments

Comments
 (0)