Skip to content

Commit

Permalink
cleanup save state logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rwynn committed Nov 22, 2019
1 parent 9b9bf6e commit 598f814
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mongofluxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,14 @@ func (im *InfluxMeasure) parseView(view string) error {

func (ctx *InfluxCtx) saveTs() (err error) {
if ctx.config.Resume && ctx.lastTs.T > 0 {
if err = ctx.writeBatch(); err != nil {
return err
}
if ctx.config.ResumeStrategy == tokenResumeStrategy {
err = saveTokens(ctx.client, ctx.tokens, ctx.config)
if err == nil {
ctx.tokens = bson.M{}
}
} else {
err = saveTimestamp(ctx.client, ctx.lastTs, ctx.config)
}
Expand Down Expand Up @@ -1043,11 +1049,10 @@ func main() {
case op, open := <-gtmCtx.OpC:
if op == nil {
if !open {
if err := influx.writeBatch(); err != nil {
if err := influx.saveTs(); err != nil {
exitStatus = 1
errorLog.Println(err)
}
influx.saveTs()
return
}
break
Expand Down

0 comments on commit 598f814

Please sign in to comment.