forked from vitessio/vitess
/
service_map.go
49 lines (41 loc) · 1.22 KB
/
service_map.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
// 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 servenv
import (
"flag"
"github.com/youtube/vitess/go/flagutil"
)
var (
serviceMapFlag flagutil.StringListValue
// ServiceMap is the exported version of the service map.
// init() functions will add default values to it.
// service_map command line parameter will alter the map.
// Can only be used after servenv.Init has been called.
ServiceMap = make(map[string]bool)
)
func init() {
flag.Var(&serviceMapFlag, "service_map", "services to enable / disable")
onInit(func() {
updateServiceMap()
})
}
// InitServiceMapForBsonRpcService will set the default entries for a
// bson rpc to serve the service.
func InitServiceMapForBsonRpcService(name string) {
ServiceMap["bsonrpc-vt-"+name] = true
ServiceMap["bsonrpc-auth-vt-"+name] = true
ServiceMap["bsonrpc-vts-"+name] = true
ServiceMap["bsonrpc-auth-vts-"+name] = true
ServiceMap["bsonrpc-unix-"+name] = true
ServiceMap["bsonrpc-auth-unix-"+name] = true
}
func updateServiceMap() {
for _, s := range serviceMapFlag {
if s[0] == '-' {
delete(ServiceMap, s[1:])
} else {
ServiceMap[s] = true
}
}
}