work on flags
This commit is contained in:
@@ -6,16 +6,19 @@ import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"git.k-space.ee/k-space/logmower-shipper/pkg/globals"
|
||||
m "git.k-space.ee/k-space/logmower-shipper/pkg/mongo"
|
||||
"github.com/jtagcat/util"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
var (
|
||||
Simulate = false
|
||||
MaxBatchItems = 1000
|
||||
)
|
||||
|
||||
const (
|
||||
MaxBatchItems = 10000
|
||||
MaxBatchTime = 5 * time.Second
|
||||
MaxBatchTime = 5 * time.Second
|
||||
)
|
||||
|
||||
type Queue <-chan m.Record
|
||||
@@ -86,14 +89,14 @@ func (queue Queue) Sender(db *mongo.Collection, metricsFilename string, cancelOn
|
||||
}
|
||||
|
||||
func insertManyWithSimulate(db *mongo.Collection, batch []m.Record) (*mongo.InsertManyResult, error) {
|
||||
if !globals.Simulate {
|
||||
if !Simulate {
|
||||
var batchBson []interface{} // mongo does not like typing
|
||||
for _, b := range batch {
|
||||
batchBson = append(batchBson, b.ToBson())
|
||||
}
|
||||
|
||||
tru := true
|
||||
return db.InsertMany(globals.MongoTimeout(context.Background()), batchBson, &options.InsertManyOptions{Ordered: &tru})
|
||||
return db.InsertMany(m.GlobalTimeout(context.Background()), batchBson, &options.InsertManyOptions{Ordered: &tru})
|
||||
}
|
||||
|
||||
fmt.Printf("simulating successful database bulk write: %v", batch)
|
||||
|
||||
Reference in New Issue
Block a user