aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api/s3api_server.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/s3api/s3api_server.go')
-rw-r--r--weed/s3api/s3api_server.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.go
index fc5c47c43..fe069595d 100644
--- a/weed/s3api/s3api_server.go
+++ b/weed/s3api/s3api_server.go
@@ -1,7 +1,9 @@
package s3api
import (
+ "context"
"fmt"
+ "net"
"net/http"
"strings"
"time"
@@ -24,6 +26,7 @@ type S3ApiServerOption struct {
BucketsPath string
GrpcDialOption grpc.DialOption
AllowEmptyFolder bool
+ LocalFilerSocket *string
}
type S3ApiServer struct {
@@ -31,6 +34,7 @@ type S3ApiServer struct {
iam *IdentityAccessManagement
randomClientId int32
filerGuard *security.Guard
+ client *http.Client
}
func NewS3ApiServer(router *mux.Router, option *S3ApiServerOption) (s3ApiServer *S3ApiServer, err error) {
@@ -49,6 +53,20 @@ func NewS3ApiServer(router *mux.Router, option *S3ApiServerOption) (s3ApiServer
randomClientId: util.RandomInt32(),
filerGuard: security.NewGuard([]string{}, signingKey, expiresAfterSec, readSigningKey, readExpiresAfterSec),
}
+ if option.LocalFilerSocket == nil {
+ s3ApiServer.client = &http.Client{Transport: &http.Transport{
+ MaxIdleConns: 1024,
+ MaxIdleConnsPerHost: 1024,
+ }}
+ } else {
+ s3ApiServer.client = &http.Client{
+ Transport: &http.Transport{
+ DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
+ return net.Dial("unix", *option.LocalFilerSocket)
+ },
+ },
+ }
+ }
s3ApiServer.registerRouter(router)