all: use time.Since() instead of time.Now().Sub
Patch created with: gofmt -w -r 'time.Now().Sub(a) -> time.Since(a)' .
This commit is contained in:
parent
97496d9a7e
commit
e02a49449e
@ -259,7 +259,7 @@ func (this *MigrationContext) IsTransactionalTable() bool {
|
|||||||
|
|
||||||
// ElapsedTime returns time since very beginning of the process
|
// ElapsedTime returns time since very beginning of the process
|
||||||
func (this *MigrationContext) ElapsedTime() time.Duration {
|
func (this *MigrationContext) ElapsedTime() time.Duration {
|
||||||
return time.Now().Sub(this.StartTime)
|
return time.Since(this.StartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarkRowCopyStartTime
|
// MarkRowCopyStartTime
|
||||||
@ -280,7 +280,7 @@ func (this *MigrationContext) ElapsedRowCopyTime() time.Duration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if this.RowCopyEndTime.IsZero() {
|
if this.RowCopyEndTime.IsZero() {
|
||||||
return time.Now().Sub(this.RowCopyStartTime)
|
return time.Since(this.RowCopyStartTime)
|
||||||
}
|
}
|
||||||
return this.RowCopyEndTime.Sub(this.RowCopyStartTime)
|
return this.RowCopyEndTime.Sub(this.RowCopyStartTime)
|
||||||
}
|
}
|
||||||
@ -314,7 +314,7 @@ func (this *MigrationContext) TimeSincePointOfInterest() time.Duration {
|
|||||||
this.pointOfInterestTimeMutex.Lock()
|
this.pointOfInterestTimeMutex.Lock()
|
||||||
defer this.pointOfInterestTimeMutex.Unlock()
|
defer this.pointOfInterestTimeMutex.Unlock()
|
||||||
|
|
||||||
return time.Now().Sub(this.pointOfInterestTime)
|
return time.Since(this.pointOfInterestTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MigrationContext) SetMaxLagMillisecondsThrottleThreshold(maxLagMillisecondsThrottleThreshold int64) {
|
func (this *MigrationContext) SetMaxLagMillisecondsThrottleThreshold(maxLagMillisecondsThrottleThreshold int64) {
|
||||||
|
@ -419,7 +419,7 @@ func (this *Applier) ApplyIterationInsertQuery() (chunkSize int64, rowsAffected
|
|||||||
return chunkSize, rowsAffected, duration, err
|
return chunkSize, rowsAffected, duration, err
|
||||||
}
|
}
|
||||||
rowsAffected, _ = sqlResult.RowsAffected()
|
rowsAffected, _ = sqlResult.RowsAffected()
|
||||||
duration = time.Now().Sub(startTime)
|
duration = time.Since(startTime)
|
||||||
log.Debugf(
|
log.Debugf(
|
||||||
"Issued INSERT on range: [%s]..[%s]; iteration: %d; chunk-size: %d",
|
"Issued INSERT on range: [%s]..[%s]; iteration: %d; chunk-size: %d",
|
||||||
this.migrationContext.MigrationIterationRangeMinValues,
|
this.migrationContext.MigrationIterationRangeMinValues,
|
||||||
|
@ -333,7 +333,7 @@ func (this *Migrator) onChangelogHeartbeat(heartbeatValue string) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return log.Errore(err)
|
return log.Errore(err)
|
||||||
}
|
}
|
||||||
lag := time.Now().Sub(heartbeatTime)
|
lag := time.Since(heartbeatTime)
|
||||||
|
|
||||||
atomic.StoreInt64(&this.migrationContext.CurrentLag, int64(lag))
|
atomic.StoreInt64(&this.migrationContext.CurrentLag, int64(lag))
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ func (this *Migrator) waitForEventsUpToLock() (err error) {
|
|||||||
log.Infof("Waiting for events up to lock")
|
log.Infof("Waiting for events up to lock")
|
||||||
atomic.StoreInt64(&this.allEventsUpToLockProcessedInjectedFlag, 1)
|
atomic.StoreInt64(&this.allEventsUpToLockProcessedInjectedFlag, 1)
|
||||||
<-this.allEventsUpToLockProcessed
|
<-this.allEventsUpToLockProcessed
|
||||||
waitForEventsUpToLockDuration := time.Now().Sub(waitForEventsUpToLockStartTime)
|
waitForEventsUpToLockDuration := time.Since(waitForEventsUpToLockStartTime)
|
||||||
|
|
||||||
log.Infof("Done waiting for events up to lock; duration=%+v", waitForEventsUpToLockDuration)
|
log.Infof("Done waiting for events up to lock; duration=%+v", waitForEventsUpToLockDuration)
|
||||||
this.printStatus(ForcePrintStatusAndHint)
|
this.printStatus(ForcePrintStatusAndHint)
|
||||||
@ -1193,7 +1193,7 @@ func (this *Migrator) executeWriteFuncs() error {
|
|||||||
return log.Errore(err)
|
return log.Errore(err)
|
||||||
}
|
}
|
||||||
if niceRatio := this.migrationContext.GetNiceRatio(); niceRatio > 0 {
|
if niceRatio := this.migrationContext.GetNiceRatio(); niceRatio > 0 {
|
||||||
copyRowsDuration := time.Now().Sub(copyRowsStartTime)
|
copyRowsDuration := time.Since(copyRowsStartTime)
|
||||||
sleepTimeNanosecondFloat64 := niceRatio * float64(copyRowsDuration.Nanoseconds())
|
sleepTimeNanosecondFloat64 := niceRatio * float64(copyRowsDuration.Nanoseconds())
|
||||||
sleepTime := time.Duration(time.Duration(int64(sleepTimeNanosecondFloat64)) * time.Nanosecond)
|
sleepTime := time.Duration(time.Duration(int64(sleepTimeNanosecondFloat64)) * time.Nanosecond)
|
||||||
time.Sleep(sleepTime)
|
time.Sleep(sleepTime)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user