renaming of variables and updating comment

This commit is contained in:
Felix Kunde 2022-05-18 11:19:41 +02:00
parent 29376afed4
commit fcc2813f13
1 changed files with 6 additions and 6 deletions

View File

@ -194,17 +194,17 @@ type ClusterMember struct {
type ReplicationLag uint64
// UnmarshalJSON implements the json.Unmarshaller interface.
func (pl *ReplicationLag) UnmarshalJSON(value []byte) error {
// UnmarshalJSON converts member lag (can be int or string) into uint64
func (rl *ReplicationLag) UnmarshalJSON(data []byte) error {
var lagUInt64 uint64
if value[0] == '"' {
*pl = math.MaxUint64
if data[0] == '"' {
*rl = math.MaxUint64
return nil
}
if err := json.Unmarshal(value, &lagUInt64); err != nil {
if err := json.Unmarshal(data, &lagUInt64); err != nil {
return err
}
*pl = ReplicationLag(lagUInt64)
*rl = ReplicationLag(lagUInt64)
return nil
}