work on flags

This commit is contained in:
2022-11-11 17:09:12 +02:00
parent 2ded62f641
commit 0b3d382742
7 changed files with 67 additions and 67 deletions

View File

@@ -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)