work on flags
This commit is contained in:
@@ -7,8 +7,8 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.k-space.ee/k-space/logmower-shipper/pkg/globals"
|
||||
"git.k-space.ee/k-space/logmower-shipper/pkg/lines"
|
||||
m "git.k-space.ee/k-space/logmower-shipper/pkg/mongo"
|
||||
"git.k-space.ee/k-space/logmower-shipper/pkg/sender"
|
||||
@@ -21,6 +21,16 @@ import (
|
||||
|
||||
const SendQueueLimit = 1024
|
||||
|
||||
// wrapper to force copying before use
|
||||
func backoff() wait.Backoff {
|
||||
return wait.Backoff{
|
||||
Duration: 2 * time.Second,
|
||||
Factor: 1.5,
|
||||
Jitter: 0.1,
|
||||
Cap: 30 * time.Second,
|
||||
}
|
||||
}
|
||||
|
||||
type File struct {
|
||||
*m.File
|
||||
MetricsName string // filepath.Base()
|
||||
@@ -28,7 +38,7 @@ type File struct {
|
||||
|
||||
// TODO: caller could call duplicate shipFile of same name on file replace: sends might not work properly
|
||||
func (f File) Process(ctx context.Context, db *mongo.Collection) {
|
||||
_ = wait.ManagedExponentialBackoffWithContext(ctx, globals.Backoff(), func() (done bool, _ error) {
|
||||
_ = wait.ManagedExponentialBackoffWithContext(ctx, backoff(), func() (done bool, _ error) {
|
||||
err := f.process(ctx, db)
|
||||
if err == nil {
|
||||
return true, nil
|
||||
@@ -74,7 +84,7 @@ func (f File) process(ctx context.Context, db *mongo.Collection) error {
|
||||
defer dfn()
|
||||
|
||||
// get files with offset
|
||||
offsetResult, _ := mongoWithErr(db.FindOne(globals.MongoTimeout(sctx),
|
||||
offsetResult, _ := mongoWithErr(db.FindOne(m.GlobalTimeout(sctx),
|
||||
bson.D{{Key: m.RecordKeyHostId, Value: f.Host.Id}, {Key: m.RecordKeyFilePath, Value: f.Path}},
|
||||
&mongoOpt.FindOneOptions{Sort: bson.D{{Key: m.RecordKeyOffset, Value: -1}}}, // sort descending (get largest)
|
||||
))
|
||||
|
Reference in New Issue
Block a user