forked from vitessio/vitess
/
cell.go
34 lines (28 loc) · 806 Bytes
/
cell.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright 2013, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package zktopo
import (
"sort"
"golang.org/x/net/context"
"github.com/youtube/vitess/go/vt/topo"
"github.com/youtube/vitess/go/zk"
)
/*
This file contains the cell management methods of zktopo.Server
*/
// GetKnownCells is part of the topo.Server interface
func (zkts *Server) GetKnownCells(ctx context.Context) ([]string, error) {
cellsWithGlobal, err := zk.ZkKnownCells()
if err != nil {
return cellsWithGlobal, convertError(err)
}
cells := make([]string, 0, len(cellsWithGlobal))
for _, cell := range cellsWithGlobal {
if cell != topo.GlobalCell {
cells = append(cells, cell)
}
}
sort.Strings(cells)
return cells, nil
}