зеркало из https://github.com/github/vitess-gh.git
Added function to derive shard name for SrvShard.
This commit is contained in:
Родитель
4d66eaf0e4
Коммит
0a767f58ab
|
@ -6,6 +6,7 @@ package topo
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/youtube/vitess/go/bson"
|
||||
|
@ -13,6 +14,10 @@ import (
|
|||
"github.com/youtube/vitess/go/vt/key"
|
||||
)
|
||||
|
||||
// This is the shard name for when the keyrange covers the entire space
|
||||
// for unsharded database.
|
||||
const SHARD_ZERO = "0"
|
||||
|
||||
// SrvShard contains a roll-up of the shard in the local namespace.
|
||||
// In zk, it is under /zk/local/vt/ns/<keyspace>/<shard>
|
||||
type SrvShard struct {
|
||||
|
@ -120,6 +125,13 @@ func (ss *SrvShard) UnmarshalBson(buf *bytes.Buffer) {
|
|||
}
|
||||
}
|
||||
|
||||
func (ss *SrvShard) ShardName() string {
|
||||
if !ss.KeyRange.IsPartial() {
|
||||
return SHARD_ZERO
|
||||
}
|
||||
return fmt.Sprintf("%v-%v", ss.KeyRange.Start, ss.KeyRange.End)
|
||||
}
|
||||
|
||||
// KeyspacePartition represents a continuous set of shards to
|
||||
// serve an entire data set.
|
||||
type KeyspacePartition struct {
|
||||
|
|
Загрузка…
Ссылка в новой задаче