diff options
| author | chrislu <chris.lu@gmail.com> | 2022-03-07 02:00:14 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-03-07 02:00:14 -0800 |
| commit | da3d330616663e1c843514bd7a7a2c1833bf42d1 (patch) | |
| tree | 8bb184b6a49b099876f1856f68c21db594ff62cc /weed/s3api/s3api_server.go | |
| parent | 0cb17b45b108340033de06d71cf2fc1b891c3be8 (diff) | |
| download | seaweedfs-da3d330616663e1c843514bd7a7a2c1833bf42d1.tar.xz seaweedfs-da3d330616663e1c843514bd7a7a2c1833bf42d1.zip | |
s3 and filer transport using unix domain socket instead of tcp
Diffstat (limited to 'weed/s3api/s3api_server.go')
| -rw-r--r-- | weed/s3api/s3api_server.go | 18 |
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) |
