You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
869 B

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