Skip to content

Commit 2ccf2af

Browse files
committed
topom: work with fsclient
1 parent 76c9db4 commit 2ccf2af

4 files changed

Lines changed: 7 additions & 29 deletions

File tree

‎cmd/dashboard/main.go‎

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import (
1414
"github.com/docopt/docopt-go"
1515

1616
"github.com/CodisLabs/codis/pkg/models"
17-
"github.com/CodisLabs/codis/pkg/models/etcd"
18-
"github.com/CodisLabs/codis/pkg/models/zk"
1917
"github.com/CodisLabs/codis/pkg/topom"
2018
"github.com/CodisLabs/codis/pkg/utils"
2119
"github.com/CodisLabs/codis/pkg/utils/log"
@@ -87,31 +85,11 @@ Options:
8785
log.Warnf("option --host-admin = %s", s)
8886
}
8987

90-
var client models.Client
91-
92-
switch config.CoordinatorName {
93-
94-
case "zookeeper":
95-
addr := config.CoordinatorAddr
96-
client, err = zkclient.New(addr, time.Minute)
97-
if err != nil {
98-
log.PanicErrorf(err, "create zkclient to %s failed", addr)
99-
}
100-
defer client.Close()
101-
102-
case "etcd":
103-
addr := config.CoordinatorAddr
104-
client, err = etcdclient.New(addr, time.Minute)
105-
if err != nil {
106-
log.PanicErrorf(err, "create etcdclient to %s failed", addr)
107-
}
108-
defer client.Close()
109-
110-
default:
111-
112-
log.Panicf("invalid coordinator name = '%s'", config.CoordinatorName)
113-
88+
client, err := models.NewClient(config.CoordinatorName, config.CoordinatorAddr, time.Minute)
89+
if err != nil {
90+
log.PanicErrorf(err, "create '%s' client to '%s' failed", config.CoordinatorName, config.CoordinatorAddr)
11491
}
92+
defer client.Close()
11593

11694
s, err := topom.New(client, config)
11795
if err != nil {

‎config/dashboard.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# #
66
##################################################
77

8-
# Set Coordinator, only accept "zookeeper" & "etcd".
8+
# Set Coordinator, only accept "zookeeper" & "etcd" & "filestore".
99
coordinator_name = "zookeeper"
1010
coordinator_addr = "127.0.0.1:2181"
1111

‎pkg/models/client.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Client interface {
2828
CreateEphemeralInOrder(path string, data []byte) (<-chan struct{}, string, error)
2929
}
3030

31-
var ErrUnknownCoordinator = errors.New("unknown coordinator")
31+
var ErrUnknownCoordinator = errors.New("unknown or invalid coordinator name")
3232

3333
func NewClient(coordinator string, addrlist string, timeout time.Duration) (Client, error) {
3434
switch coordinator {

‎pkg/topom/config.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const DefaultConfig = `
2020
# #
2121
##################################################
2222
23-
# Set Coordinator, only accept "zookeeper" & "etcd".
23+
# Set Coordinator, only accept "zookeeper" & "etcd" & "filestore".
2424
coordinator_name = "zookeeper"
2525
coordinator_addr = "127.0.0.1:2181"
2626

0 commit comments

Comments
 (0)