From ed3cf811f576e2dd9fd1c1fb0df967d7fb9e6f1c Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 29 Apr 2020 13:26:02 -0700 Subject: [PATCH] refactoring --- weed/filesys/meta_cache/meta_cache.go | 2 +- weed/filesys/wfs.go | 2 ++ weed/messaging/broker/broker_append.go | 6 ++++++ weed/messaging/client/subscriber.go | 2 +- weed/replication/sink/filersink/fetch_write.go | 2 ++ weed/replication/source/filer_source.go | 10 ++++++++-- weed/s3api/s3api_handlers.go | 2 ++ weed/server/webdav_server.go | 2 ++ weed/shell/command_fs_lock_unlock.go | 1 - weed/shell/command_fs_meta_save.go | 2 +- weed/shell/commands.go | 2 ++ 11 files changed, 27 insertions(+), 6 deletions(-) diff --git a/weed/filesys/meta_cache/meta_cache.go b/weed/filesys/meta_cache/meta_cache.go index f3416ca18..2b899103e 100644 --- a/weed/filesys/meta_cache/meta_cache.go +++ b/weed/filesys/meta_cache/meta_cache.go @@ -34,4 +34,4 @@ func openMetaStore(dbFolder string) filer2.FilerStore { return store -} \ No newline at end of file +} diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index 33403aaf8..67dd2a62c 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -117,6 +117,8 @@ func (wfs *WFS) Root() (fs.Node, error) { return wfs.root, nil } +var _ = filer_pb.FilerClient(&WFS{}) + func (wfs *WFS) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error { err := pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error { diff --git a/weed/messaging/broker/broker_append.go b/weed/messaging/broker/broker_append.go index 7194dfcfc..26f24f4d3 100644 --- a/weed/messaging/broker/broker_append.go +++ b/weed/messaging/broker/broker_append.go @@ -98,6 +98,8 @@ func (broker *MessageBroker) assignAndUpload(topicConfig *messaging_pb.TopicConf return assignResult, uploadResult, nil } +var _ = filer_pb.FilerClient(&MessageBroker{}) + func (broker *MessageBroker) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) (err error) { for _, filer := range broker.option.Filers { @@ -111,3 +113,7 @@ func (broker *MessageBroker) WithFilerClient(fn func(filer_pb.SeaweedFilerClient return } + +func (broker *MessageBroker) AdjustedUrl(hostAndPort string) string { + return hostAndPort +} diff --git a/weed/messaging/client/subscriber.go b/weed/messaging/client/subscriber.go index ddf1f82e6..2ebad4ce6 100644 --- a/weed/messaging/client/subscriber.go +++ b/weed/messaging/client/subscriber.go @@ -85,7 +85,7 @@ func (s *Subscriber) doSubscribe(partition int, processFn func(m *messaging_pb.M // Subscribe starts goroutines to process the messages func (s *Subscriber) Subscribe(processFn func(m *messaging_pb.Message)) { - for i:=0;i 0 { diff --git a/weed/s3api/s3api_handlers.go b/weed/s3api/s3api_handlers.go index b6f3d4334..45a7cbc2e 100644 --- a/weed/s3api/s3api_handlers.go +++ b/weed/s3api/s3api_handlers.go @@ -38,6 +38,8 @@ func encodeResponse(response interface{}) []byte { return bytesBuffer.Bytes() } +var _ = filer_pb.FilerClient(&S3ApiServer{}) + func (s3a *S3ApiServer) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error { return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error { diff --git a/weed/server/webdav_server.go b/weed/server/webdav_server.go index 11b89677f..f195b09f7 100644 --- a/weed/server/webdav_server.go +++ b/weed/server/webdav_server.go @@ -110,6 +110,8 @@ func NewWebDavFileSystem(option *WebDavOption) (webdav.FileSystem, error) { }, nil } +var _ = filer_pb.FilerClient(&WebDavFileSystem{}) + func (fs *WebDavFileSystem) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error { return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error { diff --git a/weed/shell/command_fs_lock_unlock.go b/weed/shell/command_fs_lock_unlock.go index a173d6c85..8a6e8f71b 100644 --- a/weed/shell/command_fs_lock_unlock.go +++ b/weed/shell/command_fs_lock_unlock.go @@ -52,4 +52,3 @@ func (c *commandUnlock) Do(args []string, commandEnv *CommandEnv, writer io.Writ return nil } - diff --git a/weed/shell/command_fs_meta_save.go b/weed/shell/command_fs_meta_save.go index a5efb69ba..ed19e3d01 100644 --- a/weed/shell/command_fs_meta_save.go +++ b/weed/shell/command_fs_meta_save.go @@ -140,4 +140,4 @@ func doTraverseBfsAndSaving(filerClient filer_pb.FilerClient, writer io.Writer, fmt.Fprintf(writer, "total %d directories, %d files\n", dirCount, fileCount) } return err -} \ No newline at end of file +} diff --git a/weed/shell/commands.go b/weed/shell/commands.go index a43196b62..b7ca5d268 100644 --- a/weed/shell/commands.go +++ b/weed/shell/commands.go @@ -92,6 +92,8 @@ func (ce *CommandEnv) checkDirectory(path string) error { } +var _ = filer_pb.FilerClient(&CommandEnv{}) + func (ce *CommandEnv) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error { filerGrpcAddress := fmt.Sprintf("%s:%d", ce.option.FilerHost, ce.option.FilerPort+10000)