Skip to content

Commit f6b9ef6

Browse files
authored
Remove NodeCommon codegen (#328)
When used as embedded field it will make types appear to support serializer, when it doesn't. No functional change.
1 parent f8ad085 commit f6b9ef6

File tree

7 files changed

+325
-316
lines changed

7 files changed

+325
-316
lines changed

health.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ import (
4747
"github.com/shirou/gopsutil/v3/process"
4848
)
4949

50+
// NodeCommon - Common fields across most node-specific health structs
51+
type NodeCommon struct {
52+
Addr string `json:"addr"`
53+
Error string `json:"error,omitempty"`
54+
}
55+
56+
// GetAddr - return the address of the node
57+
func (n *NodeCommon) GetAddr() string {
58+
return n.Addr
59+
}
60+
61+
// SetAddr - set the address of the node
62+
func (n *NodeCommon) SetAddr(addr string) {
63+
n.Addr = addr
64+
}
65+
66+
// SetError - set the address of the node
67+
func (n *NodeCommon) SetError(err string) {
68+
n.Error = err
69+
}
70+
5071
const (
5172
// HealthInfoVersion0 is version 0
5273
HealthInfoVersion0 = ""

metrics.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,15 @@ func (n *NetMetrics) Merge(other *NetMetrics) {
622622
n.NetStats.TxCompressed += other.NetStats.TxCompressed
623623
}
624624

625+
//msgp:replace NodeCommon with:nodeCommon
626+
627+
// nodeCommon - use as replacement for NodeCommon
628+
// We do not want to give NodeCommon codegen, since it is used for embedding.
629+
type nodeCommon struct {
630+
Addr string `json:"addr"`
631+
Error string `json:"error,omitempty"`
632+
}
633+
625634
// MemInfo contains system's RAM and swap information.
626635
type MemInfo struct {
627636
NodeCommon

metrics_gen.go

Lines changed: 182 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

metrics_gen_test.go

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)