Merge pull request #1033 from dln/serverset-shard

serverset discovery: extract shard number from serverset data
This commit is contained in:
Fabian Reinartz 2015-08-27 16:42:10 +02:00
commit facf60e033

View file

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