Skip to content

Commit 1a99b12

Browse files
committed
docs
1 parent 2e666db commit 1a99b12

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

internal/util/collections.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import (
1010
"go.mongodb.org/mongo-driver/mongo"
1111
)
1212

13-
// CollectionSpec is like mongo.CollectionSpecification,
13+
// CollectionSpec is like mongo.CollectionSpecification except:
14+
// - IDIndex is a bson.Raw rather than mongo.IndexSpecification.
15+
// - It can detect unexpected fields.
1416
type CollectionSpec struct {
1517
Name string
1618
Type string
@@ -26,12 +28,15 @@ type CollectionSpec struct {
2628
Extra map[string]any
2729
}
2830

29-
// Returns full name of collection including database name
31+
// FullName returns the collection's full namespace.
3032
func FullName(collection *mongo.Collection) string {
3133
return collection.Database().Name() + "." + collection.Name()
3234
}
3335

34-
func GetCollectionSpec(
36+
// GetCollectionSpecIfExists returns the given collection’s specification,
37+
// or empty if the collection doesn’t exist. If any unexpected properties
38+
// exist in the collection specification then an error is returned.
39+
func GetCollectionSpecIfExists(
3540
ctx context.Context,
3641
coll *mongo.Collection,
3742
) (option.Option[CollectionSpec], error) {

internal/verifier/migration_verifier.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,12 +1123,12 @@ func (verifier *Verifier) verifyMetadataAndPartitionCollection(ctx context.Conte
11231123
srcNs := FullName(srcColl)
11241124
dstNs := FullName(dstColl)
11251125

1126-
srcSpecOpt, srcErr := util.GetCollectionSpec(ctx, srcColl)
1126+
srcSpecOpt, srcErr := util.GetCollectionSpecIfExists(ctx, srcColl)
11271127
if srcErr != nil {
11281128
verifier.markCollectionFailed(workerNum, task, ClusterSource, srcNs, srcErr)
11291129
}
11301130

1131-
dstSpecOpt, dstErr := util.GetCollectionSpec(ctx, dstColl)
1131+
dstSpecOpt, dstErr := util.GetCollectionSpecIfExists(ctx, dstColl)
11321132
if dstErr != nil {
11331133
verifier.markCollectionFailed(workerNum, task, ClusterTarget, dstNs, dstErr)
11341134
}

0 commit comments

Comments
 (0)