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.

31 lines
704 B

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