some code optimizations
This commit is contained in:
@@ -2,7 +2,6 @@ package s3api
|
||||
|
||||
import (
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/s3_pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/s3api/s3_config"
|
||||
"github.com/chrislusf/seaweedfs/weed/s3api/s3_constants"
|
||||
"github.com/chrislusf/seaweedfs/weed/s3api/s3err"
|
||||
"go.uber.org/atomic"
|
||||
@@ -27,30 +26,31 @@ var (
|
||||
bucket = "/test"
|
||||
action = s3_constants.ACTION_READ
|
||||
TestLimitCases = []*TestLimitCase{
|
||||
{action, s3_config.LimitTypeCount, 5, 5, 6, 1024, 5},
|
||||
{action, s3_config.LimitTypeCount, 6, 6, 6, 1024, 6},
|
||||
{action, s3_config.LimitTypeCount, 5, 6, 6, 1024, 5},
|
||||
{action, s3_config.LimitTypeBytes, 1024, 1024, 6, 200, 5},
|
||||
{action, s3_config.LimitTypeBytes, 1200, 1200, 6, 200, 6},
|
||||
{action, s3_config.LimitTypeBytes, 11990, 11990, 60, 200, 59},
|
||||
{action, s3_config.LimitTypeBytes, 11790, 11990, 60, 200, 58},
|
||||
{action, s3_constants.LimitTypeCount, 5, 5, 6, 1024, 5},
|
||||
{action, s3_constants.LimitTypeCount, 6, 6, 6, 1024, 6},
|
||||
{action, s3_constants.LimitTypeCount, 5, 6, 6, 1024, 5},
|
||||
{action, s3_constants.LimitTypeBytes, 1024, 1024, 6, 200, 5},
|
||||
{action, s3_constants.LimitTypeBytes, 1200, 1200, 6, 200, 6},
|
||||
{action, s3_constants.LimitTypeBytes, 11990, 11990, 60, 200, 59},
|
||||
{action, s3_constants.LimitTypeBytes, 11790, 11990, 60, 200, 58},
|
||||
}
|
||||
)
|
||||
|
||||
func TestLimit(t *testing.T) {
|
||||
for _, tc := range TestLimitCases {
|
||||
circuitBreakerConfig := &s3_pb.S3CircuitBreakerConfig{
|
||||
Global: &s3_pb.CbOptions{
|
||||
Global: &s3_pb.S3CircuitBreakerOptions{
|
||||
Enabled: true,
|
||||
Actions: map[string]int64{
|
||||
s3_config.Concat(tc.actionName, tc.limitType): tc.globalLimitValue,
|
||||
s3_constants.Concat(tc.actionName, tc.limitType): tc.globalLimitValue,
|
||||
s3_constants.Concat(tc.actionName, tc.limitType): tc.globalLimitValue,
|
||||
},
|
||||
},
|
||||
Buckets: map[string]*s3_pb.CbOptions{
|
||||
Buckets: map[string]*s3_pb.S3CircuitBreakerOptions{
|
||||
bucket: {
|
||||
Enabled: true,
|
||||
Actions: map[string]int64{
|
||||
s3_config.Concat(tc.actionName, tc.limitType): tc.bucketLimitValue,
|
||||
s3_constants.Concat(tc.actionName, tc.limitType): tc.bucketLimitValue,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user