aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/wfs_filer_client.go
blob: e0d352a7b6cfaf13ec23d9c9683696a3a8f94040 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package filesys

import (
	"github.com/chrislusf/seaweedfs/weed/util"
	"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 := util.Retry("filer grpc "+wfs.option.FilerGrpcAddress, func() error {
		return 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

}