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.

34 lines
804 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/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", 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.OutsideContainerClusterMode {
  23. return location.PublicUrl
  24. }
  25. return location.Url
  26. }