Skip to content

Commit 5d57f17

Browse files
rfblue2Roland Fong
authored andcommitted
Rename ConvertOption methods
GODRIVER-272 Change-Id: Ia519189379e17eb224c040d2ffb8ccd4ea6f4170
1 parent 48f5aa7 commit 5d57f17

File tree

15 files changed

+389
-399
lines changed

15 files changed

+389
-399
lines changed

mongo/aggregateopt/aggregateopt.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var aggregateBundle = new(AggregateBundle)
1414
// Aggregate is options for the aggregate() function
1515
type Aggregate interface {
1616
aggregate()
17-
ConvertOption() option.AggregateOptioner
17+
ConvertAggregateOption() option.AggregateOptioner
1818
}
1919

2020
// AggregateBundle is a bundle of Aggregate options
@@ -26,8 +26,8 @@ type AggregateBundle struct {
2626
// Implement the Aggregate interface
2727
func (ab *AggregateBundle) aggregate() {}
2828

29-
// ConvertOption implements the Aggregate interface
30-
func (ab *AggregateBundle) ConvertOption() option.AggregateOptioner { return nil }
29+
// ConvertAggregateOption implements the Aggregate interface
30+
func (ab *AggregateBundle) ConvertAggregateOption() option.AggregateOptioner { return nil }
3131

3232
// BundleAggregate bundles Aggregate options
3333
func BundleAggregate(opts ...Aggregate) *AggregateBundle {
@@ -196,7 +196,7 @@ func (ab *AggregateBundle) unbundle() ([]option.AggregateOptioner, error) {
196196
continue
197197
}
198198

199-
options[index] = listHead.option.ConvertOption()
199+
options[index] = listHead.option.ConvertAggregateOption()
200200
index--
201201
}
202202

@@ -216,7 +216,7 @@ func (ab *AggregateBundle) String() string {
216216
continue
217217
}
218218

219-
str += head.option.ConvertOption().String() + "\n"
219+
str += head.option.ConvertAggregateOption().String() + "\n"
220220
}
221221

222222
return str
@@ -264,8 +264,8 @@ type OptAllowDiskUse option.OptAllowDiskUse
264264

265265
func (OptAllowDiskUse) aggregate() {}
266266

267-
// ConvertOption implements the Aggregate interface
268-
func (opt OptAllowDiskUse) ConvertOption() option.AggregateOptioner {
267+
// ConvertAggregateOption implements the Aggregate interface
268+
func (opt OptAllowDiskUse) ConvertAggregateOption() option.AggregateOptioner {
269269
return option.OptAllowDiskUse(opt)
270270
}
271271

@@ -274,16 +274,16 @@ type OptBatchSize option.OptBatchSize
274274

275275
func (OptBatchSize) aggregate() {}
276276

277-
// ConvertOption implements the Aggregate interface
278-
func (opt OptBatchSize) ConvertOption() option.AggregateOptioner {
277+
// ConvertAggregateOption implements the Aggregate interface
278+
func (opt OptBatchSize) ConvertAggregateOption() option.AggregateOptioner {
279279
return option.OptBatchSize(opt)
280280
}
281281

282282
// OptBypassDocumentValidation allows the write to opt-out of document-level validation.
283283
type OptBypassDocumentValidation option.OptBypassDocumentValidation
284284

285-
// ConvertOption implements the Aggregate interface
286-
func (opt OptBypassDocumentValidation) ConvertOption() option.AggregateOptioner {
285+
// ConvertAggregateOption implements the Aggregate interface
286+
func (opt OptBypassDocumentValidation) ConvertAggregateOption() option.AggregateOptioner {
287287
return option.OptBypassDocumentValidation(opt)
288288
}
289289

@@ -294,8 +294,8 @@ type OptCollation option.OptCollation
294294

295295
func (OptCollation) aggregate() {}
296296

297-
// ConvertOption implements the Aggregate interface
298-
func (opt OptCollation) ConvertOption() option.AggregateOptioner {
297+
// ConvertAggregateOption implements the Aggregate interface
298+
func (opt OptCollation) ConvertAggregateOption() option.AggregateOptioner {
299299
return option.OptCollation(opt)
300300
}
301301

@@ -304,8 +304,8 @@ type OptMaxTime option.OptMaxTime
304304

305305
func (OptMaxTime) aggregate() {}
306306

307-
// ConvertOption implements the Aggregate interface
308-
func (opt OptMaxTime) ConvertOption() option.AggregateOptioner {
307+
// ConvertAggregateOption implements the Aggregate interface
308+
func (opt OptMaxTime) ConvertAggregateOption() option.AggregateOptioner {
309309
return option.OptMaxTime(opt)
310310
}
311311

@@ -314,8 +314,8 @@ type OptComment option.OptComment
314314

315315
func (OptComment) aggregate() {}
316316

317-
// ConvertOption implements the Aggregate interface
318-
func (opt OptComment) ConvertOption() option.AggregateOptioner {
317+
// ConvertAggregateOption implements the Aggregate interface
318+
func (opt OptComment) ConvertAggregateOption() option.AggregateOptioner {
319319
return option.OptComment(opt)
320320
}
321321

@@ -324,7 +324,7 @@ type OptHint option.OptHint
324324

325325
func (OptHint) aggregate() {}
326326

327-
// ConvertOption implements the Aggregate interface
328-
func (opt OptHint) ConvertOption() option.AggregateOptioner {
327+
// ConvertAggregateOption implements the Aggregate interface
328+
func (opt OptHint) ConvertAggregateOption() option.AggregateOptioner {
329329
return option.OptHint(opt)
330330
}

mongo/aggregateopt/aggregateopt_test.go

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,18 @@ func TestAggregateOpt(t *testing.T) {
5959
bundle1 = bundle1.BypassDocumentValidation(true).Comment("hello world").BypassDocumentValidation(false)
6060
testhelpers.RequireNotNil(t, bundle1, "created bundle was nil")
6161
bundle1Opts := []option.Optioner{
62-
BypassDocumentValidation(true).ConvertOption(),
63-
Comment("hello world").ConvertOption(),
64-
BypassDocumentValidation(false).ConvertOption(),
62+
BypassDocumentValidation(true).ConvertAggregateOption(),
63+
Comment("hello world").ConvertAggregateOption(),
64+
BypassDocumentValidation(false).ConvertAggregateOption(),
6565
}
6666
bundle1DedupOpts := []option.Optioner{
67-
Comment("hello world").ConvertOption(),
68-
BypassDocumentValidation(false).ConvertOption(),
67+
Comment("hello world").ConvertAggregateOption(),
68+
BypassDocumentValidation(false).ConvertAggregateOption(),
6969
}
7070

7171
bundle2 := BundleAggregate(BatchSize(1))
7272
bundle2Opts := []option.Optioner{
73-
OptBatchSize(1).ConvertOption(),
73+
OptBatchSize(1).ConvertAggregateOption(),
7474
}
7575

7676
bundle3 := BundleAggregate().
@@ -82,73 +82,73 @@ func TestAggregateOpt(t *testing.T) {
8282
Comment("World")
8383

8484
bundle3Opts := []option.Optioner{
85-
OptBatchSize(1).ConvertOption(),
86-
OptComment("Hello").ConvertOption(),
87-
OptBatchSize(2).ConvertOption(),
88-
OptBypassDocumentValidation(false).ConvertOption(),
89-
OptBypassDocumentValidation(true).ConvertOption(),
90-
OptComment("World").ConvertOption(),
85+
OptBatchSize(1).ConvertAggregateOption(),
86+
OptComment("Hello").ConvertAggregateOption(),
87+
OptBatchSize(2).ConvertAggregateOption(),
88+
OptBypassDocumentValidation(false).ConvertAggregateOption(),
89+
OptBypassDocumentValidation(true).ConvertAggregateOption(),
90+
OptComment("World").ConvertAggregateOption(),
9191
}
9292

9393
bundle3DedupOpts := []option.Optioner{
94-
OptBatchSize(2).ConvertOption(),
95-
OptBypassDocumentValidation(true).ConvertOption(),
96-
OptComment("World").ConvertOption(),
94+
OptBatchSize(2).ConvertAggregateOption(),
95+
OptBypassDocumentValidation(true).ConvertAggregateOption(),
96+
OptComment("World").ConvertAggregateOption(),
9797
}
9898

9999
nilBundle := BundleAggregate()
100100
var nilBundleOpts []option.Optioner
101101

102102
nestedBundle1 := createNestedBundle1(t)
103103
nestedBundleOpts1 := []option.Optioner{
104-
OptAllowDiskUse(true).ConvertOption(),
105-
OptMaxTime(500).ConvertOption(),
106-
OptAllowDiskUse(false).ConvertOption(),
107-
OptComment("hello world nested").ConvertOption(),
108-
OptBatchSize(1000).ConvertOption(),
104+
OptAllowDiskUse(true).ConvertAggregateOption(),
105+
OptMaxTime(500).ConvertAggregateOption(),
106+
OptAllowDiskUse(false).ConvertAggregateOption(),
107+
OptComment("hello world nested").ConvertAggregateOption(),
108+
OptBatchSize(1000).ConvertAggregateOption(),
109109
}
110110
nestedBundleDedupOpts1 := []option.Optioner{
111-
OptMaxTime(500).ConvertOption(),
112-
OptAllowDiskUse(false).ConvertOption(),
113-
OptComment("hello world nested").ConvertOption(),
114-
OptBatchSize(1000).ConvertOption(),
111+
OptMaxTime(500).ConvertAggregateOption(),
112+
OptAllowDiskUse(false).ConvertAggregateOption(),
113+
OptComment("hello world nested").ConvertAggregateOption(),
114+
OptBatchSize(1000).ConvertAggregateOption(),
115115
}
116116

117117
nestedBundle2 := createNestedBundle2(t)
118118
nestedBundleOpts2 := []option.Optioner{
119-
OptAllowDiskUse(true).ConvertOption(),
120-
OptMaxTime(500).ConvertOption(),
121-
OptMaxTime(100).ConvertOption(),
122-
OptAllowDiskUse(false).ConvertOption(),
123-
OptComment("nest1").ConvertOption(),
124-
OptComment("nest2").ConvertOption(),
125-
OptBatchSize(1000).ConvertOption(),
119+
OptAllowDiskUse(true).ConvertAggregateOption(),
120+
OptMaxTime(500).ConvertAggregateOption(),
121+
OptMaxTime(100).ConvertAggregateOption(),
122+
OptAllowDiskUse(false).ConvertAggregateOption(),
123+
OptComment("nest1").ConvertAggregateOption(),
124+
OptComment("nest2").ConvertAggregateOption(),
125+
OptBatchSize(1000).ConvertAggregateOption(),
126126
}
127127
nestedBundleDedupOpts2 := []option.Optioner{
128-
OptMaxTime(100).ConvertOption(),
129-
OptAllowDiskUse(false).ConvertOption(),
130-
OptComment("nest2").ConvertOption(),
131-
OptBatchSize(1000).ConvertOption(),
128+
OptMaxTime(100).ConvertAggregateOption(),
129+
OptAllowDiskUse(false).ConvertAggregateOption(),
130+
OptComment("nest2").ConvertAggregateOption(),
131+
OptBatchSize(1000).ConvertAggregateOption(),
132132
}
133133

134134
nestedBundle3 := createNestedBundle3(t)
135135
nestedBundleOpts3 := []option.Optioner{
136-
OptMaxTime(100).ConvertOption(),
137-
OptAllowDiskUse(true).ConvertOption(),
138-
OptComment("nest3").ConvertOption(),
139-
OptComment("nest4").ConvertOption(),
140-
OptMaxTime(500).ConvertOption(),
141-
OptMaxTime(100).ConvertOption(),
142-
OptAllowDiskUse(false).ConvertOption(),
143-
OptComment("nest1").ConvertOption(),
144-
OptComment("nest2").ConvertOption(),
145-
OptBatchSize(1000).ConvertOption(),
136+
OptMaxTime(100).ConvertAggregateOption(),
137+
OptAllowDiskUse(true).ConvertAggregateOption(),
138+
OptComment("nest3").ConvertAggregateOption(),
139+
OptComment("nest4").ConvertAggregateOption(),
140+
OptMaxTime(500).ConvertAggregateOption(),
141+
OptMaxTime(100).ConvertAggregateOption(),
142+
OptAllowDiskUse(false).ConvertAggregateOption(),
143+
OptComment("nest1").ConvertAggregateOption(),
144+
OptComment("nest2").ConvertAggregateOption(),
145+
OptBatchSize(1000).ConvertAggregateOption(),
146146
}
147147
nestedBundleDedupOpts3 := []option.Optioner{
148-
OptMaxTime(100).ConvertOption(),
149-
OptAllowDiskUse(false).ConvertOption(),
150-
OptComment("nest2").ConvertOption(),
151-
OptBatchSize(1000).ConvertOption(),
148+
OptMaxTime(100).ConvertAggregateOption(),
149+
OptAllowDiskUse(false).ConvertAggregateOption(),
150+
OptComment("nest2").ConvertAggregateOption(),
151+
OptBatchSize(1000).ConvertAggregateOption(),
152152
}
153153

154154
t.Run("TestAll", func(t *testing.T) {
@@ -175,7 +175,7 @@ func TestAggregateOpt(t *testing.T) {
175175
}
176176

177177
for i, opt := range opts {
178-
if !reflect.DeepEqual(opt.ConvertOption(), deleteOpts[i]) {
178+
if !reflect.DeepEqual(opt.ConvertAggregateOption(), deleteOpts[i]) {
179179
t.Errorf("opt mismatch. expected %#v, got %#v", opt, deleteOpts[i])
180180
}
181181
}

mongo/countopt/countopt.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var countBundle = new(CountBundle)
1212
// Count is options for the count() function
1313
type Count interface {
1414
count()
15-
ConvertOption() option.CountOptioner
15+
ConvertCountOption() option.CountOptioner
1616
}
1717

1818
// CountBundle is a bundle of Count options
@@ -24,8 +24,8 @@ type CountBundle struct {
2424
// Implement the Count interface
2525
func (cb *CountBundle) count() {}
2626

27-
// ConvertOption implements the Count interface
28-
func (cb *CountBundle) ConvertOption() option.CountOptioner {
27+
// ConvertCountOption implements the Count interface
28+
func (cb *CountBundle) ConvertCountOption() option.CountOptioner {
2929
return nil
3030
}
3131

@@ -176,7 +176,7 @@ func (cb *CountBundle) unbundle() ([]option.CountOptioner, error) {
176176
continue
177177
}
178178

179-
options[index] = listHead.option.ConvertOption()
179+
options[index] = listHead.option.ConvertCountOption()
180180
index--
181181
}
182182

@@ -196,7 +196,7 @@ func (cb *CountBundle) String() string {
196196
continue
197197
}
198198

199-
str += head.option.ConvertOption().String()
199+
str += head.option.ConvertCountOption().String()
200200
}
201201

202202
return str
@@ -234,16 +234,16 @@ type OptCollation option.OptCollation
234234

235235
func (OptCollation) count() {}
236236

237-
// ConvertOption implements the Count interface.
238-
func (opt OptCollation) ConvertOption() option.CountOptioner {
237+
// ConvertCountOption implements the Count interface.
238+
func (opt OptCollation) ConvertCountOption() option.CountOptioner {
239239
return option.OptCollation(opt)
240240
}
241241

242242
// OptLimit limits the maximum number of documents to count.
243243
type OptLimit option.OptLimit
244244

245-
// ConvertOption implements the Count interface.
246-
func (opt OptLimit) ConvertOption() option.CountOptioner {
245+
// ConvertCountOption implements the Count interface.
246+
func (opt OptLimit) ConvertCountOption() option.CountOptioner {
247247
return option.OptLimit(opt)
248248
}
249249

@@ -252,8 +252,8 @@ func (OptLimit) count() {}
252252
// OptSkip specifies the number of documents to skip before counting.
253253
type OptSkip option.OptSkip
254254

255-
// ConvertOption implements the Count interface.
256-
func (opt OptSkip) ConvertOption() option.CountOptioner {
255+
// ConvertCountOption implements the Count interface.
256+
func (opt OptSkip) ConvertCountOption() option.CountOptioner {
257257
return option.OptSkip(opt)
258258
}
259259

@@ -262,8 +262,8 @@ func (OptSkip) count() {}
262262
// OptHint specifies the index to use.
263263
type OptHint option.OptHint
264264

265-
// ConvertOption implements the Count interface.
266-
func (opt OptHint) ConvertOption() option.CountOptioner {
265+
// ConvertCountOption implements the Count interface.
266+
func (opt OptHint) ConvertCountOption() option.CountOptioner {
267267
return option.OptHint(opt)
268268
}
269269

@@ -272,8 +272,8 @@ func (OptHint) count() {}
272272
// OptMaxTimeMs specifies the maximum amount of time to allow the operation to run.
273273
type OptMaxTimeMs option.OptMaxTime
274274

275-
// ConvertOption implements the Count interface.
276-
func (opt OptMaxTimeMs) ConvertOption() option.CountOptioner {
275+
// ConvertCountOption implements the Count interface.
276+
func (opt OptMaxTimeMs) ConvertCountOption() option.CountOptioner {
277277
return option.OptMaxTime(opt)
278278
}
279279

0 commit comments

Comments
 (0)