snapshot reorg (#954)

This commit is contained in:
Michael Quigley
2025-04-25 11:23:34 -04:00
parent 5371e3bb0f
commit abd22ef906
2 changed files with 30 additions and 25 deletions

30
canary/snapshot.go Normal file
View File

@@ -0,0 +1,30 @@
package canary
import (
"fmt"
"github.com/openziti/zrok/util"
"time"
)
type Snapshot struct {
Operation string
Instance uint
Iteration uint64
Started time.Time
Completed time.Time
Ok bool
Error error
Size uint64
}
func NewSnapshot(operation string, instance uint, iteration uint64) *Snapshot {
return &Snapshot{Operation: operation, Instance: instance, Iteration: iteration, Started: time.Now()}
}
func (s *Snapshot) String() string {
if s.Ok {
return fmt.Sprintf("[%v, %d, %d] (ok) %v, %v", s.Operation, s.Instance, s.Iteration, s.Completed.Sub(s.Started), util.BytesToSize(int64(s.Size)))
} else {
return fmt.Sprintf("[%v, %d, %d] (err) %v, %v, (%v)", s.Operation, s.Instance, s.Iteration, s.Completed.Sub(s.Started), util.BytesToSize(int64(s.Size)), s.Error)
}
}

View File

@@ -4,36 +4,11 @@ import (
"context"
"fmt"
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
"github.com/openziti/zrok/util"
"github.com/sirupsen/logrus"
"slices"
"sort"
"time"
)
type Snapshot struct {
Operation string
Instance uint
Iteration uint64
Started time.Time
Completed time.Time
Ok bool
Error error
Size uint64
}
func NewSnapshot(operation string, instance uint, iteration uint64) *Snapshot {
return &Snapshot{Operation: operation, Instance: instance, Iteration: iteration, Started: time.Now()}
}
func (s *Snapshot) String() string {
if s.Ok {
return fmt.Sprintf("[%v, %d, %d] (ok) %v, %v", s.Operation, s.Instance, s.Iteration, s.Completed.Sub(s.Started), util.BytesToSize(int64(s.Size)))
} else {
return fmt.Sprintf("[%v, %d, %d] (err) %v, %v, (%v)", s.Operation, s.Instance, s.Iteration, s.Completed.Sub(s.Started), util.BytesToSize(int64(s.Size)), s.Error)
}
}
type SnapshotCollector struct {
InputQueue chan *Snapshot
Closed chan struct{}