diff options
Diffstat (limited to 'weed/wdclient')
| -rw-r--r-- | weed/wdclient/masterclient.go | 9 | ||||
| -rw-r--r-- | weed/wdclient/vid_map.go | 5 |
2 files changed, 8 insertions, 6 deletions
diff --git a/weed/wdclient/masterclient.go b/weed/wdclient/masterclient.go index da46a440b..eccf1d14b 100644 --- a/weed/wdclient/masterclient.go +++ b/weed/wdclient/masterclient.go @@ -56,13 +56,14 @@ func (mc *MasterClient) GetLookupFileIdFunction() LookupFileIdFunctionType { return mc.LookupFileIdWithFallback } -func (mc *MasterClient) LookupFileIdWithFallback(fileId string) (fullUrls []string, err error) { - fullUrls, err = mc.vidMap.LookupFileId(fileId) +func (mc *MasterClient) LookupFileIdWithFallback(ctx context.Context, fileId string) (fullUrls []string, err error) { + fullUrls, err = mc.vidMap.LookupFileId(ctx, fileId) if err == nil && len(fullUrls) > 0 { return } - err = pb.WithMasterClient(false, mc.GetMaster(context.Background()), mc.grpcDialOption, false, func(client master_pb.SeaweedClient) error { - resp, err := client.LookupVolume(context.Background(), &master_pb.LookupVolumeRequest{ + + err = pb.WithMasterClient(false, mc.GetMaster(ctx), mc.grpcDialOption, false, func(client master_pb.SeaweedClient) error { + resp, err := client.LookupVolume(ctx, &master_pb.LookupVolumeRequest{ VolumeOrFileIds: []string{fileId}, }) if err != nil { diff --git a/weed/wdclient/vid_map.go b/weed/wdclient/vid_map.go index 7a2a5bb92..9d5e5d378 100644 --- a/weed/wdclient/vid_map.go +++ b/weed/wdclient/vid_map.go @@ -1,6 +1,7 @@ package wdclient import ( + "context" "errors" "fmt" "github.com/seaweedfs/seaweedfs/weed/pb" @@ -21,7 +22,7 @@ type HasLookupFileIdFunction interface { GetLookupFileIdFunction() LookupFileIdFunctionType } -type LookupFileIdFunctionType func(fileId string) (targetUrls []string, err error) +type LookupFileIdFunctionType func(ctx context.Context, fileId string) (targetUrls []string, err error) type Location struct { Url string `json:"url,omitempty"` @@ -99,7 +100,7 @@ func (vc *vidMap) LookupVolumeServerUrl(vid string) (serverUrls []string, err er return } -func (vc *vidMap) LookupFileId(fileId string) (fullUrls []string, err error) { +func (vc *vidMap) LookupFileId(ctx context.Context, fileId string) (fullUrls []string, err error) { parts := strings.Split(fileId, ",") if len(parts) != 2 { return nil, errors.New("Invalid fileId " + fileId) |
