aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api/s3api_handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/s3api/s3api_handlers.go')
-rw-r--r--weed/s3api/s3api_handlers.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/weed/s3api/s3api_handlers.go b/weed/s3api/s3api_handlers.go
index 281fc9000..d7212d5e3 100644
--- a/weed/s3api/s3api_handlers.go
+++ b/weed/s3api/s3api_handlers.go
@@ -5,12 +5,15 @@ import (
"encoding/base64"
"encoding/xml"
"fmt"
- "github.com/chrislusf/seaweedfs/weed/glog"
- "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
- "github.com/chrislusf/seaweedfs/weed/util"
"net/http"
"net/url"
"time"
+
+ "google.golang.org/grpc"
+
+ "github.com/chrislusf/seaweedfs/weed/glog"
+ "github.com/chrislusf/seaweedfs/weed/pb"
+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
)
type mimeType string
@@ -37,15 +40,11 @@ func encodeResponse(response interface{}) []byte {
func (s3a *S3ApiServer) withFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
- grpcConnection, err := util.GrpcDial(s3a.option.FilerGrpcAddress)
- if err != nil {
- return fmt.Errorf("fail to dial %s: %v", s3a.option.FilerGrpcAddress, err)
- }
- defer grpcConnection.Close()
-
- client := filer_pb.NewSeaweedFilerClient(grpcConnection)
+ return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
+ client := filer_pb.NewSeaweedFilerClient(grpcConnection)
+ return fn(client)
+ }, s3a.option.FilerGrpcAddress, s3a.option.GrpcDialOption)
- return fn(client)
}
// If none of the http routes match respond with MethodNotAllowed
@@ -77,6 +76,7 @@ func writeResponse(w http.ResponseWriter, statusCode int, response []byte, mType
}
w.WriteHeader(statusCode)
if response != nil {
+ glog.V(4).Infof("status %d %s: %s", statusCode, mType, string(response))
w.Write(response)
w.(http.Flusher).Flush()
}