mirror of
https://github.com/openziti/zrok.git
synced 2025-08-19 12:24:37 +02:00
snapshot reorg (#954)
This commit is contained in:
30
canary/snapshot.go
Normal file
30
canary/snapshot.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
@@ -4,36 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
|
||||||
"github.com/openziti/zrok/util"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
"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 {
|
type SnapshotCollector struct {
|
||||||
InputQueue chan *Snapshot
|
InputQueue chan *Snapshot
|
||||||
Closed chan struct{}
|
Closed chan struct{}
|
Reference in New Issue
Block a user