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.

27 lines
941 B

5 years ago
6 years ago
5 years ago
6 years ago
5 years ago
6 years ago
  1. package operation
  2. import (
  3. "google.golang.org/grpc"
  4. "github.com/chrislusf/seaweedfs/weed/pb"
  5. "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
  6. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  7. )
  8. func WithVolumeServerClient(volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(volume_server_pb.VolumeServerClient) error) error {
  9. return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
  10. client := volume_server_pb.NewVolumeServerClient(grpcConnection)
  11. return fn(client)
  12. }, volumeServer.ToGrpcAddress(), grpcDialOption)
  13. }
  14. func WithMasterServerClient(masterServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(masterClient master_pb.SeaweedClient) error) error {
  15. return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
  16. client := master_pb.NewSeaweedClient(grpcConnection)
  17. return fn(client)
  18. }, masterServer.ToGrpcAddress(), grpcDialOption)
  19. }