wfs_filer_client.go 839 B

12345678910111213141516171819202122232425262728293031323334
  1. package filesys
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/util"
  4. "google.golang.org/grpc"
  5. "github.com/chrislusf/seaweedfs/weed/pb"
  6. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  7. )
  8. var _ = filer_pb.FilerClient(&WFS{})
  9. func (wfs *WFS) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
  10. err := util.Retry("filer grpc "+wfs.option.FilerGrpcAddress, func() error {
  11. return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
  12. client := filer_pb.NewSeaweedFilerClient(grpcConnection)
  13. return fn(client)
  14. }, wfs.option.FilerGrpcAddress, wfs.option.GrpcDialOption)
  15. })
  16. if err == nil {
  17. return nil
  18. }
  19. return err
  20. }
  21. func (wfs *WFS) AdjustedUrl(location *filer_pb.Location) string {
  22. if wfs.option.VolumeServerAccess == "publicUrl" {
  23. return location.PublicUrl
  24. }
  25. return location.Url
  26. }