Skip to content

Commit

Permalink
update 3.23.12
Browse files Browse the repository at this point in the history
  • Loading branch information
noaccident committed Jan 10, 2024
1 parent 7c22360 commit ecf74b3
Show file tree
Hide file tree
Showing 19 changed files with 222 additions and 193 deletions.
35 changes: 0 additions & 35 deletions Help on License

This file was deleted.

19 changes: 1 addition & 18 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


## OPEN SOURCE SOFTWARE NOTICE
This document contains open source software notice for this product. And this document is confidential information of copyright holder. Recipient shall protect it in due care and shall not disseminate it without permission.

### Warranty Disclaimer
THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.

### Copyright Notice and License Texts

### Written Offer
This product contains software whose rights holders license it on the terms of the GNU General Public License, version 2 (GPLv2) or other open source software license. We will provide you with the source code of the software licensed under related license if you send us a written request by mail or email to the following addresses:
[email protected]
detailing the name of the product and the firmware version for which you need the source code and indicating how we can contact you.

**PLEASE NOTE THAT WE WILL ASK YOU TO PAY US FOR THE COSTS OF A DATA CARRIER AND THE POSTAL CHARGES TO SEND THE DATA CARRIER TO YOU. THIS OFFER IS VALID FOR THREE YEARS FROM THE MOMENT WE DISTRIBUTED THE PRODUCT AND VALID FOR AS LONG AS WE OFFER SPARE PARTS OR CUSTOMER SUPPORT FOR THAT PRODUCT MODEL.**

limitations under the License.
7 changes: 7 additions & 0 deletions Open Source Software Notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## OPEN SOURCE SOFTWARE NOTICE
This document contains open source software notice for this product. And this document is confidential information of copyright holder. Recipient shall protect it in due care and shall not disseminate it without permission.

### Warranty Disclaimer
THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.

### Copyright Notice and License Texts
13 changes: 13 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
Version 3.23.12

New Features:
1. Added obs.WithDisableKeepAlive method to implement short connection function.
2. Added deep archive storage-class.

Documentation & Demo:

Resolved Issues:
1. Fixed the issue where bucket life cycle configuration failed in some scenarios.

-----------------------------------------------------------------------------------

Version 3.23.9

New Features:
Expand Down
12 changes: 12 additions & 0 deletions README_CN.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Version 3.23.12

新特性:
1. 新增obs.WithDisableKeepAlive方法实现使用短连接功能。
2. 新增深度归档存储类别。

资料&demo:

修复问题:
1. 修复部分场景下设置桶的生命周期配置失败的问题。
-----------------------------------------------------------------------------------

Version 3.23.9

新特性:
Expand Down
6 changes: 3 additions & 3 deletions main/obs_go_sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -1701,11 +1701,11 @@ func putFileWithProgress() {

func appendObjectWithProgress() {
input := &obs.AppendObjectInput{}
input.Bucket = bucketName
input.Bucket = bucketName
input.Key = objectKey
input.Position = 9
input.Body = strings.NewReader("Hello OBS")
output, err := getObsClient().AppendObject(input, obs.WithProgress(&ObsProgressListener{}))
input.Body = strings.NewReader("Hello OBS")
output, err := getObsClient().AppendObject(input, obs.WithProgress(&ObsProgressListener{}))
if err == nil {
fmt.Printf("Append object(%s) under the bucket(%s) successful!\n", input.Key, input.Bucket)
fmt.Printf("ETag:%s, NextAppendPosition:%d\n", output.ETag, output.NextAppendPosition)
Expand Down
84 changes: 42 additions & 42 deletions obs/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,34 @@ type urlHolder struct {
}

type config struct {
securityProviders []securityProvider
urlHolder *urlHolder
pathStyle bool
cname bool
sslVerify bool
endpoint string
signature SignatureType
region string
connectTimeout int
socketTimeout int
headerTimeout int
idleConnTimeout int
finalTimeout int
maxRetryCount int
proxyURL string
noProxyURL string
proxyFromEnv bool
maxConnsPerHost int
pemCerts []byte
transport *http.Transport
roundTripper http.RoundTripper
httpClient *http.Client
ctx context.Context
maxRedirectCount int
userAgent string
enableCompression bool
progressListener ProgressListener

securityProviders []securityProvider
urlHolder *urlHolder
pathStyle bool
cname bool
sslVerify bool
disableKeepAlive bool
endpoint string
signature SignatureType
region string
connectTimeout int
socketTimeout int
headerTimeout int
idleConnTimeout int
finalTimeout int
maxRetryCount int
proxyURL string
noProxyURL string
proxyFromEnv bool
maxConnsPerHost int
pemCerts []byte
transport *http.Transport
roundTripper http.RoundTripper
httpClient *http.Client
ctx context.Context
maxRedirectCount int
userAgent string
enableCompression bool
progressListener ProgressListener
customProxyOnce sync.Once
customProxyFuncValue func(*url.URL) (*url.URL, error)
}
Expand Down Expand Up @@ -232,6 +232,13 @@ func WithCustomDomainName(cname bool) configurer {
}
}

// WithDisableKeepAlive is a configurer for ObsClient to disable the keep-alive for http.
func WithDisableKeepAlive(disableKeepAlive bool) configurer {
return func(conf *config) {
conf.disableKeepAlive = disableKeepAlive
}
}

// WithMaxRedirectCount is a configurer for ObsClient to set the maximum number of times that the request is redirected.
func WithMaxRedirectCount(maxRedirectCount int) configurer {
return func(conf *config) {
Expand Down Expand Up @@ -365,6 +372,7 @@ func (conf *config) getTransport() error {
MaxIdleConnsPerHost: conf.maxConnsPerHost,
ResponseHeaderTimeout: time.Second * time.Duration(conf.headerTimeout),
IdleConnTimeout: time.Second * time.Duration(conf.idleConnTimeout),
DisableKeepAlives: conf.disableKeepAlive,
}
if conf.proxyURL != "" {
conf.transport.Proxy = conf.customProxyFromEnvironment
Expand Down Expand Up @@ -543,19 +551,11 @@ func getQueryURL(key, value string) string {
return queryURL
}

var once sync.Once

func (obsClient ObsClient) GetClientConfigure(extensions []extensionOptions) *config {
once.Do(func() {
for _, extension := range extensions {
if configure, ok := extension.(configurer); ok {
configure(obsClient.conf)
}
}
})
return obsClient.conf
}

func (obsClient ObsClient) getProgressListener(extensions []extensionOptions) ProgressListener {
return obsClient.GetClientConfigure(extensions).progressListener
for _, extension := range extensions {
if configure, ok := extension.(extensionProgressListener); ok {
return configure()
}
}
return nil
}
11 changes: 10 additions & 1 deletion obs/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package obs

const (
OBS_SDK_VERSION = "3.23.4"
OBS_SDK_VERSION = "3.23.12"
USER_AGENT = "obs-sdk-go/" + OBS_SDK_VERSION
HEADER_PREFIX = "x-amz-"
HEADER_PREFIX_META = "x-amz-meta-"
Expand Down Expand Up @@ -288,5 +288,14 @@ var (
"ignore-sign-in-query": true,
"name": true,
"rename": true,
"customdomain": true,
"mirrorbacktosource": true,
}

obsStorageClasses = []string{
string(StorageClassStandard),
string(StorageClassWarm),
string(StorageClassCold),
string(StorageClassDeepArchive),
}
)
46 changes: 25 additions & 21 deletions obs/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ func ParseStringToEventType(value string) (ret EventType) {
// ParseStringToStorageClassType converts string value to StorageClassType value and returns it
func ParseStringToStorageClassType(value string) (ret StorageClassType) {
switch value {
case "STANDARD":
case string(StorageClassStandard):
ret = StorageClassStandard
case "STANDARD_IA", "WARM":
case string(storageClassStandardIA), string(StorageClassWarm):
ret = StorageClassWarm
case "GLACIER", "COLD":
case string(storageClassGlacier), string(StorageClassCold):
ret = StorageClassCold
case string(StorageClassDeepArchive):
ret = StorageClassDeepArchive
default:
ret = ""
}
Expand Down Expand Up @@ -348,7 +350,7 @@ func convertTransitionsToXML(transitions []Transition, isObs bool) string {
return ""
}

func converLifeCycleFilterToXML(filter LifecycleFilter) string {
func convertLifeCycleFilterToXML(filter LifecycleFilter) string {
if filter.Prefix == "" && len(filter.Tags) == 0 {
return ""
}
Expand All @@ -369,6 +371,7 @@ func convertExpirationToXML(expiration Expiration) string {
}
return ""
}

func convertNoncurrentVersionTransitionsToXML(noncurrentVersionTransitions []NoncurrentVersionTransition, isObs bool) string {
if length := len(noncurrentVersionTransitions); length > 0 {
xml := make([]string, 0, length)
Expand Down Expand Up @@ -405,37 +408,38 @@ func convertAbortIncompleteMultipartUploadToXML(abortIncompleteMultipartUpload A
return ""
}

// ConvertLifecyleConfigurationToXml converts BucketLifecyleConfiguration value to XML data and returns it
func ConvertLifecyleConfigurationToXml(input BucketLifecyleConfiguration, returnMd5 bool, isObs bool) (data string, md5 string) {
// ConvertLifecycleConfigurationToXml converts BucketLifecycleConfiguration value to XML data and returns it
func ConvertLifecycleConfigurationToXml(input BucketLifecycleConfiguration, returnMd5 bool, isObs bool) (data string, md5 string) {
xml := make([]string, 0, 2+len(input.LifecycleRules)*9)
xml = append(xml, "<LifecycleConfiguration>")
for _, lifecyleRule := range input.LifecycleRules {
for _, lifecycleRule := range input.LifecycleRules {
xml = append(xml, "<Rule>")
if lifecyleRule.ID != "" {
lifecyleRuleID := XmlTranscoding(lifecyleRule.ID)
xml = append(xml, fmt.Sprintf("<ID>%s</ID>", lifecyleRuleID))
if lifecycleRule.ID != "" {
lifecycleRuleID := XmlTranscoding(lifecycleRule.ID)
xml = append(xml, fmt.Sprintf("<ID>%s</ID>", lifecycleRuleID))
}
lifecyleRulePrefix := XmlTranscoding(lifecyleRule.Prefix)
if lifecyleRulePrefix != "" {
xml = append(xml, fmt.Sprintf("<Prefix>%s</Prefix>", lifecyleRulePrefix))
lifecycleRulePrefix := XmlTranscoding(lifecycleRule.Prefix)
lifecycleRuleFilter := convertLifeCycleFilterToXML(lifecycleRule.Filter)
if lifecycleRulePrefix != "" || (lifecycleRulePrefix == "" && lifecycleRuleFilter == "") {
xml = append(xml, fmt.Sprintf("<Prefix>%s</Prefix>", lifecycleRulePrefix))
}
xml = append(xml, fmt.Sprintf("<Status>%s</Status>", lifecyleRule.Status))
if ret := converLifeCycleFilterToXML(lifecyleRule.Filter); ret != "" {
xml = append(xml, ret)
if lifecycleRuleFilter != "" {
xml = append(xml, lifecycleRuleFilter)
}
if ret := convertTransitionsToXML(lifecyleRule.Transitions, isObs); ret != "" {
xml = append(xml, fmt.Sprintf("<Status>%s</Status>", lifecycleRule.Status))
if ret := convertTransitionsToXML(lifecycleRule.Transitions, isObs); ret != "" {
xml = append(xml, ret)
}
if ret := convertExpirationToXML(lifecyleRule.Expiration); ret != "" {
if ret := convertExpirationToXML(lifecycleRule.Expiration); ret != "" {
xml = append(xml, ret)
}
if ret := convertNoncurrentVersionTransitionsToXML(lifecyleRule.NoncurrentVersionTransitions, isObs); ret != "" {
if ret := convertNoncurrentVersionTransitionsToXML(lifecycleRule.NoncurrentVersionTransitions, isObs); ret != "" {
xml = append(xml, ret)
}
if ret := convertNoncurrentVersionExpirationToXML(lifecyleRule.NoncurrentVersionExpiration); ret != "" {
if ret := convertNoncurrentVersionExpirationToXML(lifecycleRule.NoncurrentVersionExpiration); ret != "" {
xml = append(xml, ret)
}
if ret := convertAbortIncompleteMultipartUploadToXML(lifecyleRule.AbortIncompleteMultipartUpload); ret != "" {
if ret := convertAbortIncompleteMultipartUploadToXML(lifecycleRule.AbortIncompleteMultipartUpload); ret != "" {
xml = append(xml, ret)
}
xml = append(xml, "</Rule>")
Expand Down
8 changes: 5 additions & 3 deletions obs/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import (

type extensionOptions interface{}
type extensionHeaders func(headers map[string][]string, isObs bool) error
type extensionProgressListener func() ProgressListener

func WithProgress(progressListener ProgressListener) configurer {
return func(conf *config) {
conf.progressListener = progressListener
func WithProgress(progressListener ProgressListener) extensionProgressListener {
return func() ProgressListener {
return progressListener
}
}

func setHeaderPrefix(key string, value string) extensionHeaders {
return func(headers map[string][]string, isObs bool) error {
if strings.TrimSpace(value) == "" {
Expand Down
Loading

0 comments on commit ecf74b3

Please sign in to comment.