forked from joeholley/supergloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistration_snapshot.sk.go
75 lines (59 loc) · 1.77 KB
/
registration_snapshot.sk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Code generated by solo-kit. DO NOT EDIT.
package v1
import (
"fmt"
"github.com/solo-io/go-utils/hashutils"
"go.uber.org/zap"
)
type RegistrationSnapshot struct {
Meshes MeshList
Meshingresses MeshIngressList
}
func (s RegistrationSnapshot) Clone() RegistrationSnapshot {
return RegistrationSnapshot{
Meshes: s.Meshes.Clone(),
Meshingresses: s.Meshingresses.Clone(),
}
}
func (s RegistrationSnapshot) Hash() uint64 {
return hashutils.HashAll(
s.hashMeshes(),
s.hashMeshingresses(),
)
}
func (s RegistrationSnapshot) hashMeshes() uint64 {
return hashutils.HashAll(s.Meshes.AsInterfaces()...)
}
func (s RegistrationSnapshot) hashMeshingresses() uint64 {
return hashutils.HashAll(s.Meshingresses.AsInterfaces()...)
}
func (s RegistrationSnapshot) HashFields() []zap.Field {
var fields []zap.Field
fields = append(fields, zap.Uint64("meshes", s.hashMeshes()))
fields = append(fields, zap.Uint64("meshingresses", s.hashMeshingresses()))
return append(fields, zap.Uint64("snapshotHash", s.Hash()))
}
type RegistrationSnapshotStringer struct {
Version uint64
Meshes []string
Meshingresses []string
}
func (ss RegistrationSnapshotStringer) String() string {
s := fmt.Sprintf("RegistrationSnapshot %v\n", ss.Version)
s += fmt.Sprintf(" Meshes %v\n", len(ss.Meshes))
for _, name := range ss.Meshes {
s += fmt.Sprintf(" %v\n", name)
}
s += fmt.Sprintf(" Meshingresses %v\n", len(ss.Meshingresses))
for _, name := range ss.Meshingresses {
s += fmt.Sprintf(" %v\n", name)
}
return s
}
func (s RegistrationSnapshot) Stringer() RegistrationSnapshotStringer {
return RegistrationSnapshotStringer{
Version: s.Hash(),
Meshes: s.Meshes.NamespacesDotNames(),
Meshingresses: s.Meshingresses.NamespacesDotNames(),
}
}