forked from vitessio/vitess
/
config.go
108 lines (83 loc) · 2.92 KB
/
config.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright 2014, 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 etcdtopo
import (
"flag"
"path"
"github.com/youtube/vitess/go/flagutil"
topodatapb "github.com/youtube/vitess/go/vt/proto/topodata"
"github.com/youtube/vitess/go/vt/topo/topoproto"
)
const (
// Paths within the etcd keyspace.
rootPath = "/vt"
cellsDirPath = rootPath + "/cells"
keyspacesDirPath = rootPath + "/keyspaces"
tabletsDirPath = rootPath + "/tablets"
replicationDirPath = rootPath + "/replication"
servingDirPath = rootPath + "/ns"
// Magic file names. Directories in etcd cannot have data. Files whose names
// begin with '_' are hidden from directory listings.
dataFilename = "_Data"
keyspaceFilename = dataFilename
shardFilename = dataFilename
tabletFilename = dataFilename
shardReplicationFilename = dataFilename
srvKeyspaceFilename = dataFilename
vschemaFilename = "_VSchema"
)
var (
globalAddrs flagutil.StringListValue
)
func init() {
flag.Var(&globalAddrs, "etcd_global_addrs", "comma-separated list of addresses (http://host:port) for global etcd cluster")
}
func cellFilePath(cell string) string {
return path.Join(cellsDirPath, cell)
}
func keyspaceDirPath(keyspace string) string {
return path.Join(keyspacesDirPath, keyspace)
}
func keyspaceFilePath(keyspace string) string {
return path.Join(keyspaceDirPath(keyspace), keyspaceFilename)
}
func vschemaFilePath(keyspace string) string {
return path.Join(keyspaceDirPath(keyspace), vschemaFilename)
}
func shardsDirPath(keyspace string) string {
return keyspaceDirPath(keyspace)
}
func shardDirPath(keyspace, shard string) string {
return path.Join(shardsDirPath(keyspace), shard)
}
func shardFilePath(keyspace, shard string) string {
return path.Join(shardDirPath(keyspace, shard), shardFilename)
}
func tabletDirPath(tabletAlias *topodatapb.TabletAlias) string {
return path.Join(tabletsDirPath, topoproto.TabletAliasString(tabletAlias))
}
func tabletFilePath(tabletAlias *topodatapb.TabletAlias) string {
return path.Join(tabletDirPath(tabletAlias), tabletFilename)
}
func keyspaceReplicationDirPath(keyspace string) string {
return path.Join(replicationDirPath, keyspace)
}
func shardReplicationDirPath(keyspace, shard string) string {
return path.Join(keyspaceReplicationDirPath(keyspace), shard)
}
func shardReplicationFilePath(keyspace, shard string) string {
return path.Join(shardReplicationDirPath(keyspace, shard), shardReplicationFilename)
}
func srvKeyspaceDirPath(keyspace string) string {
return path.Join(servingDirPath, keyspace)
}
func srvKeyspaceFilePath(keyspace string) string {
return path.Join(srvKeyspaceDirPath(keyspace), srvKeyspaceFilename)
}
func srvVSchemaDirPath() string {
return servingDirPath
}
func srvVSchemaFilePath() string {
return path.Join(srvVSchemaDirPath(), vschemaFilename)
}