serverset: extract shard number from serverset data

This commit is contained in:
Daniel Lundin 2015-08-26 16:53:37 +02:00
parent 29eaa8c7cf
commit 4abf54b747

View file

@ -17,6 +17,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"strconv"
"strings"
"sync"
"time"
@ -36,12 +37,14 @@ const (
serversetStatusLabel = serversetLabelPrefix + "status"
serversetPathLabel = serversetLabelPrefix + "path"
serversetEndpointLabelPrefix = serversetLabelPrefix + "endpoint"
serversetShardLabel = serversetLabelPrefix + "shard"
)
type serversetMember struct {
ServiceEndpoint serversetEndpoint
AdditionalEndpoints map[string]serversetEndpoint
Status string `json:"status"`
Shard int `json:"shard"`
}
type serversetEndpoint struct {
@ -168,6 +171,7 @@ func parseServersetMember(data []byte, path string) (*model.LabelSet, error) {
}
labels[serversetStatusLabel] = model.LabelValue(member.Status)
labels[serversetShardLabel] = model.LabelValue(strconv.Itoa(member.Shard))
return &labels, nil
}