SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
refactoring
Chris Luce3630e7a4ad
diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.goindex 6b3ef8f3ce..93f72ad65a 100644--- a/weed/filesys/wfs.go+++ b/weed/filesys/wfs.go@@ -6,7 +6,6 @@ import ("math""os""path"- "strings""sync""time"@@ -19,7 +18,6 @@ import ("github.com/chrislusf/seaweedfs/weed/filesys/meta_cache""github.com/chrislusf/seaweedfs/weed/glog"- "github.com/chrislusf/seaweedfs/weed/pb""github.com/chrislusf/seaweedfs/weed/pb/filer_pb""github.com/chrislusf/seaweedfs/weed/util""github.com/chrislusf/seaweedfs/weed/util/chunk_cache"@@ -115,22 +113,6 @@ 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 {- client := filer_pb.NewSeaweedFilerClient(grpcConnection)- return fn(client)- }, wfs.option.FilerGrpcAddress, wfs.option.GrpcDialOption)-- if err == nil {- return nil- }- return err--}-func (wfs *WFS) AcquireHandle(file *File, uid, gid uint32) (fileHandle *FileHandle) {fullpath := file.fullpath()@@ -225,16 +207,3 @@ func (wfs *WFS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.return nil}--func (wfs *WFS) AdjustedUrl(hostAndPort string) string {- if !wfs.option.OutsideContainerClusterMode {- return hostAndPort- }- commaIndex := strings.Index(hostAndPort, ":")- if commaIndex < 0 {- return hostAndPort- }- filerCommaIndex := strings.Index(wfs.option.FilerGrpcAddress, ":")- return fmt.Sprintf("%s:%s", wfs.option.FilerGrpcAddress[:filerCommaIndex], hostAndPort[commaIndex+1:])--}diff --git a/weed/filesys/wfs_filer_client.go b/weed/filesys/wfs_filer_client.gonew file mode 100644index 0000000000..736df3588b--- /dev/null+++ b/weed/filesys/wfs_filer_client.go@@ -0,0 +1,40 @@+package filesys++import (+ "fmt"+ "strings"++ "google.golang.org/grpc"++ "github.com/chrislusf/seaweedfs/weed/pb"+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"+)++var _ = filer_pb.FilerClient(&WFS{})++func (wfs *WFS) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {++ err := pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {+ client := filer_pb.NewSeaweedFilerClient(grpcConnection)+ return fn(client)+ }, wfs.option.FilerGrpcAddress, wfs.option.GrpcDialOption)++ if err == nil {+ return nil+ }+ return err++}++func (wfs *WFS) AdjustedUrl(hostAndPort string) string {+ if !wfs.option.OutsideContainerClusterMode {+ return hostAndPort+ }+ commaIndex := strings.Index(hostAndPort, ":")+ if commaIndex < 0 {+ return hostAndPort+ }+ filerCommaIndex := strings.Index(wfs.option.FilerGrpcAddress, ":")+ return fmt.Sprintf("%s:%s", wfs.option.FilerGrpcAddress[:filerCommaIndex], hostAndPort[commaIndex+1:])++}