refactoring function parameter
This commit is contained in:
@@ -238,7 +238,7 @@ func (fs *FilerServer) AssignVolume(ctx context.Context, req *filer_pb.AssignVol
|
|||||||
|
|
||||||
func (fs *FilerServer) DeleteCollection(ctx context.Context, req *filer_pb.DeleteCollectionRequest) (resp *filer_pb.DeleteCollectionResponse, err error) {
|
func (fs *FilerServer) DeleteCollection(ctx context.Context, req *filer_pb.DeleteCollectionRequest) (resp *filer_pb.DeleteCollectionResponse, err error) {
|
||||||
|
|
||||||
err = fs.filer.MasterClient.WithClient(ctx, func(ctx context.Context, client master_pb.SeaweedClient) error {
|
err = fs.filer.MasterClient.WithClient(ctx, func(client master_pb.SeaweedClient) error {
|
||||||
_, err := client.CollectionDelete(ctx, &master_pb.CollectionDeleteRequest{
|
_, err := client.CollectionDelete(ctx, &master_pb.CollectionDeleteRequest{
|
||||||
Name: req.GetCollection(),
|
Name: req.GetCollection(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ func (c *commandCollectionList) Help() string {
|
|||||||
func (c *commandCollectionList) Do(args []string, commandEnv *commandEnv, writer io.Writer) (err error) {
|
func (c *commandCollectionList) Do(args []string, commandEnv *commandEnv, writer io.Writer) (err error) {
|
||||||
|
|
||||||
var resp *master_pb.CollectionListResponse
|
var resp *master_pb.CollectionListResponse
|
||||||
|
ctx := context.Background()
|
||||||
err = commandEnv.masterClient.WithClient(context.Background(), func(ctx context.Context, client master_pb.SeaweedClient) error {
|
err = commandEnv.masterClient.WithClient(ctx, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err = client.CollectionList(ctx, &master_pb.CollectionListRequest{})
|
resp, err = client.CollectionList(ctx, &master_pb.CollectionListRequest{})
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ func (c *commandVolumeList) Help() string {
|
|||||||
func (c *commandVolumeList) Do(args []string, commandEnv *commandEnv, writer io.Writer) (err error) {
|
func (c *commandVolumeList) Do(args []string, commandEnv *commandEnv, writer io.Writer) (err error) {
|
||||||
|
|
||||||
var resp *master_pb.VolumeListResponse
|
var resp *master_pb.VolumeListResponse
|
||||||
err = commandEnv.masterClient.WithClient(context.Background(), func(ctx context.Context, client master_pb.SeaweedClient) error {
|
ctx := context.Background()
|
||||||
|
err = commandEnv.masterClient.WithClient(ctx, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err = client.VolumeList(ctx, &master_pb.VolumeListRequest{})
|
resp, err = client.VolumeList(ctx, &master_pb.VolumeListRequest{})
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ func withMasterClient(ctx context.Context, master string, grpcDialOption grpc.Di
|
|||||||
return fn(ctx, client)
|
return fn(ctx, client)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MasterClient) WithClient(ctx context.Context, fn func(ctx context.Context, client master_pb.SeaweedClient) error) error {
|
func (mc *MasterClient) WithClient(ctx context.Context, fn func(client master_pb.SeaweedClient) error) error {
|
||||||
return withMasterClient(ctx, mc.currentMaster, mc.grpcDialOption, func(ctx context.Context, client master_pb.SeaweedClient) error {
|
return withMasterClient(ctx, mc.currentMaster, mc.grpcDialOption, func(ctx context.Context, client master_pb.SeaweedClient) error {
|
||||||
return fn(ctx, client)
|
return fn(client)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user