aboutsummaryrefslogtreecommitdiff
path: root/weed/wdclient/wdclient.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-07-27 01:54:45 -0700
committerChris Lu <chris.lu@gmail.com>2018-07-27 01:54:45 -0700
commit0d989491993a98753bf34569f74791c87cecb900 (patch)
treebd64cdbe7ca1156792059d9fc7647e254481ba38 /weed/wdclient/wdclient.go
parente4b7e31902d6fe181f3257fd943d5fa75a7d4d2d (diff)
downloadseaweedfs-0d989491993a98753bf34569f74791c87cecb900.tar.xz
seaweedfs-0d989491993a98753bf34569f74791c87cecb900.zip
tmp commit
Diffstat (limited to 'weed/wdclient/wdclient.go')
-rw-r--r--weed/wdclient/wdclient.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/weed/wdclient/wdclient.go b/weed/wdclient/wdclient.go
new file mode 100644
index 000000000..cbe03359f
--- /dev/null
+++ b/weed/wdclient/wdclient.go
@@ -0,0 +1,42 @@
+package wdclient
+
+import (
+ "context"
+ "code.uber.internal/fraud/alpine/.gen/proto/go/fraud/alpine"
+)
+
+type SeaweedClient struct {
+ ctx context.Context
+ Master string
+ ClientName string
+ ClusterListener *clusterlistener.ClusterListener
+}
+
+// NewSeaweedClient creates a SeaweedFS client which contains a listener for the Seaweed system topology changes
+func NewSeaweedClient(ctx context.Context, clientName, master string) *SeaweedClient {
+ c := &SeaweedClient{
+ ctx: ctx,
+ Master: master,
+ ClusterListener: clusterlistener.NewClusterListener(clientName),
+ ClientName: clientName,
+ }
+ c.ClusterListener.StartListener(ctx, c.Master)
+
+ conn, err := grpc.Dial(c.Master, grpc.WithInsecure())
+ if err != nil {
+ glog.Fatalf("%s fail to dial %v: %v", c.ClientName, c.Master, err)
+ }
+ c.MasterClient = pb.NewAlpineMasterClient(conn)
+
+ return c
+}
+
+// NewClusterClient create a lightweight client to access a specific cluster
+// TODO The call will block if the keyspace is not created in this data center.
+func (c *SeaweedClient) NewClusterClient(keyspace string) (clusterClient *ClusterClient) {
+
+ return &ClusterClient{
+ keyspace: keyspace,
+ }
+
+}