Skip to content

Commit

Permalink
Merge pull request #1143 from himanshuvar/HuaweiSFS
Browse files Browse the repository at this point in the history
[FileShare Support] Fixed Fileshare APIs Response Timeout
  • Loading branch information
skdwriting authored Oct 19, 2020
2 parents d9de4ba + 478c097 commit eda7c0b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/pkg/file/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package file
import (
"context"
"net/http"
"time"

"github.com/emicklei/go-restful"
"github.com/micro/go-micro/v2/client"
Expand Down Expand Up @@ -118,6 +119,7 @@ func (s *APIService) ListFileShare(request *restful.Request, response *restful.R
log.Info("Received request for File Share List.")

ctx := common.InitCtxWithAuthInfo(request)
ctx, _ = context.WithTimeout(ctx, 5 * time.Minute)

backendId := request.QueryParameter(common.REQUEST_PATH_BACKEND_ID)

Expand Down Expand Up @@ -193,6 +195,7 @@ func (s *APIService) GetFileShare(request *restful.Request, response *restful.Re
id := request.PathParameter("id")

ctx := common.InitCtxWithAuthInfo(request)
ctx, _ = context.WithTimeout(ctx, 5 * time.Minute)

res, err := s.fileClient.GetFileShare(ctx, &file.GetFileShareRequest{Id: id})
if err != nil {
Expand Down Expand Up @@ -271,6 +274,7 @@ func (s *APIService) CreateFileShare(request *restful.Request, response *restful
}

ctx := common.InitCtxWithAuthInfo(request)
ctx, _ = context.WithTimeout(ctx, 5 * time.Minute)

if s.checkBackendExists(ctx, request, response, fs.BackendId) != nil {
return
Expand Down Expand Up @@ -341,6 +345,7 @@ func (s *APIService) UpdateFileShare(request *restful.Request, response *restful
id := request.PathParameter("id")

ctx := common.InitCtxWithAuthInfo(request)
ctx, _ = context.WithTimeout(ctx, 5 * time.Minute)

actx := request.Attribute(c.KContext).(*c.Context)
fs.TenantId = actx.TenantId
Expand All @@ -366,6 +371,7 @@ func (s *APIService) DeleteFileShare(request *restful.Request, response *restful
log.Infof("Received request for deleting file share: %s\n", id)

ctx := common.InitCtxWithAuthInfo(request)
ctx, _ = context.WithTimeout(ctx, 5 * time.Minute)

res, err := s.fileClient.DeleteFileShare(ctx, &file.DeleteFileShareRequest{Id: id})
if err != nil {
Expand Down

0 comments on commit eda7c0b

Please sign in to comment.