feat: replace NewBetchInserter function name (#2769)

This commit is contained in:
MarkJoyMa
2023-01-09 09:38:57 +08:00
committed by GitHub
parent 0c786ca849
commit 0defb7522f
2 changed files with 5 additions and 32 deletions

View File

@@ -25,25 +25,15 @@ type (
}
)
// Deprecated. Use NewBatchInserter instead.
func NewBulkInserter(coll *mongo.Collection, interval ...time.Duration) *BulkInserter {
return newBulkInserter(coll, interval...)
}
// NewBatchInserter returns a BulkInserter.
func NewBatchInserter(coll Collection, interval ...time.Duration) (*BulkInserter, error) {
// NewBulkInserter returns a BulkInserter.
func NewBulkInserter(coll Collection, interval ...time.Duration) (*BulkInserter, error) {
cloneColl, err := coll.Clone()
if err != nil {
return nil, err
}
return newBulkInserter(cloneColl, interval...), nil
}
// newBulkInserter returns a BulkInserter.
func newBulkInserter(coll *mongo.Collection, interval ...time.Duration) *BulkInserter {
inserter := &dbInserter{
collection: coll,
collection: cloneColl,
}
duration := flushInterval
@@ -54,7 +44,7 @@ func newBulkInserter(coll *mongo.Collection, interval ...time.Duration) *BulkIns
return &BulkInserter{
executor: executors.NewPeriodicalExecutor(duration, inserter),
inserter: inserter,
}
}, nil
}
// Flush flushes the inserter, writes all pending records.