- update vendor

master
李光春 11 months ago
parent 1d7ef4fb34
commit b2ee634db1

@ -6,13 +6,13 @@ require (
github.com/MercuryEngineering/CookieMonster v0.0.0-20180304172713-1584578b3403
github.com/aliyun/aliyun-oss-go-sdk v2.2.7+incompatible
github.com/allegro/bigcache/v3 v3.1.0
github.com/baidubce/bce-sdk-go v0.9.150
github.com/baidubce/bce-sdk-go v0.9.151
github.com/basgys/goxml2json v1.1.0
github.com/bytedance/sonic v1.9.1
github.com/gin-gonic/gin v1.9.1
github.com/go-playground/locales v0.14.1
github.com/go-playground/universal-translator v0.18.1
github.com/go-playground/validator/v10 v10.14.0
github.com/go-playground/validator/v10 v10.14.1
github.com/go-sql-driver/mysql v1.7.1
github.com/goccy/go-json v0.10.2
github.com/gogf/gf/v2 v2.4.2
@ -22,14 +22,14 @@ require (
github.com/mvdan/xurls v1.1.0
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/oschwald/geoip2-golang v1.8.0
github.com/qiniu/go-sdk/v7 v7.15.0
github.com/qiniu/go-sdk/v7 v7.16.0
github.com/redis/go-redis/v9 v9.0.5
github.com/robfig/cron/v3 v3.0.1
github.com/saracen/go7z v0.0.0-20191010121135-9c09b6bd7fda
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/sirupsen/logrus v1.9.3
github.com/tencentyun/cos-go-sdk-v5 v0.7.41
go.mongodb.org/mongo-driver v1.11.6
go.mongodb.org/mongo-driver v1.11.7
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.9.0
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1

@ -32,8 +32,8 @@ github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6l
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/baidubce/bce-sdk-go v0.9.150 h1:8IC7hfvSi2P2WqitUbJUNnGcd8+5edVUZQkMKpHetd0=
github.com/baidubce/bce-sdk-go v0.9.150/go.mod h1:zbYJMQwE4IZuyrJiFO8tO8NbtYiKTFTbwh4eIsqjVdg=
github.com/baidubce/bce-sdk-go v0.9.151 h1:AWCcndmlt29ti2iJ9Re1pInOOnAplY2KGMAsN3LCTjw=
github.com/baidubce/bce-sdk-go v0.9.151/go.mod h1:zbYJMQwE4IZuyrJiFO8tO8NbtYiKTFTbwh4eIsqjVdg=
github.com/basgys/goxml2json v1.1.0 h1:4ln5i4rseYfXNd86lGEB+Vi652IsIXIvggKM/BhUKVw=
github.com/basgys/goxml2json v1.1.0/go.mod h1:wH7a5Np/Q4QoECFIU8zTQlZwZkrilY0itPfecMw41Dw=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
@ -133,8 +133,8 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk=
github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js=
github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k=
github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
@ -447,8 +447,8 @@ github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/qiniu/dyn v1.3.0/go.mod h1:E8oERcm8TtwJiZvkQPbcAh0RL8jO1G0VXJMW3FAWdkk=
github.com/qiniu/go-sdk/v7 v7.15.0 h1:vkxZZHM2Ed0qHeIx7NF3unXav+guaVIXlEsCCkpQAww=
github.com/qiniu/go-sdk/v7 v7.15.0/go.mod h1:nqoYCNo53ZlGA521RvRethvxUDvXKt4gtYXOwye868w=
github.com/qiniu/go-sdk/v7 v7.16.0 h1:Jt4YOMLuaDfgb/KdVg0O1fYLpv5MDkYe/zV+Ri7gWRs=
github.com/qiniu/go-sdk/v7 v7.16.0/go.mod h1:nqoYCNo53ZlGA521RvRethvxUDvXKt4gtYXOwye868w=
github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/redis/go-redis/v9 v9.0.5 h1:CuQcn5HIEeK7BgElubPP8CGtE0KakrnbBSTLjathl5o=
@ -558,8 +558,8 @@ github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxt
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
go.mongodb.org/mongo-driver v1.11.6 h1:XM7G6PjiGAO5betLF13BIa5TlLUUE3uJ/2Ox3Lz1K+o=
go.mongodb.org/mongo-driver v1.11.6/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
go.mongodb.org/mongo-driver v1.11.7 h1:LIwYxASDLGUg/8wOhgOOZhX8tQa/9tgZPgzZoVqJvcs=
go.mongodb.org/mongo-driver v1.11.7/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=

@ -26,7 +26,7 @@ import (
// Constants and default values for the package bce
const (
SDK_VERSION = "0.9.150"
SDK_VERSION = "0.9.151"
URI_PREFIX = "/" // now support uri without prefix "v1" so just set root path
DEFAULT_DOMAIN = "baidubce.com"
DEFAULT_PROTOCOL = "http"

@ -1,7 +1,7 @@
Package validator
=================
<img align="right" src="https://raw.githubusercontent.com/go-playground/validator/v10/logo.png">[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Project status](https://img.shields.io/badge/version-10.14.0-green.svg)
![Project status](https://img.shields.io/badge/version-10.14.1-green.svg)
[![Build Status](https://travis-ci.org/go-playground/validator.svg?branch=master)](https://travis-ci.org/go-playground/validator)
[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-playground/validator?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator)

@ -1414,25 +1414,21 @@ func isURL(fl FieldLevel) bool {
switch field.Kind() {
case reflect.String:
var i int
s := field.String()
// checks needed as of Go 1.6 because of change https://github.com/golang/go/commit/617c93ce740c3c3cc28cdd1a0d712be183d0b328#diff-6c2d018290e298803c0c9419d8739885L195
// emulate browser and strip the '#' suffix prior to validation. see issue-#237
if i = strings.Index(s, "#"); i > -1 {
s = s[:i]
}
if len(s) == 0 {
return false
}
url, err := url.ParseRequestURI(s)
url, err := url.Parse(s)
if err != nil || url.Scheme == "" {
return false
}
if url.Host == "" && url.Fragment == "" && url.Opaque == "" {
return false
}
return true
}
@ -1450,7 +1446,13 @@ func isHttpURL(fl FieldLevel) bool {
case reflect.String:
s := strings.ToLower(field.String())
return strings.HasPrefix(s, "http://") || strings.HasPrefix(s, "https://")
url, err := url.Parse(s)
if err != nil || url.Host == "" {
return false
}
return url.Scheme == "http" || url.Scheme == "https"
}
panic(fmt.Sprintf("Bad field type %T", field.Interface()))
@ -2568,9 +2570,17 @@ func isDirPath(fl FieldLevel) bool {
func isJSON(fl FieldLevel) bool {
field := fl.Field()
if field.Kind() == reflect.String {
switch field.Kind() {
case reflect.String:
val := field.String()
return json.Valid([]byte(val))
case reflect.Slice:
fieldType := field.Type()
if fieldType.ConvertibleTo(byteSliceType) {
b := field.Convert(byteSliceType).Interface().([]byte)
return json.Valid(b)
}
}
panic(fmt.Sprintf("Bad field type %T", field.Interface()))

@ -53,6 +53,8 @@ var (
timeDurationType = reflect.TypeOf(time.Duration(0))
timeType = reflect.TypeOf(time.Time{})
byteSliceType = reflect.TypeOf([]byte{})
defaultCField = &cField{namesEqual: true}
)

@ -1,12 +1,19 @@
# Changelog
## 7.16.0
* 新增
* 对象存储,`BucketManager` `BucketsV4` 获取该用户的指定区域内的空间信息,注意该 API 以分页形式返回 Bucket 列表
* 对象存储,`BucketManager` `SetRemark` 设置空间的备注信息
* 更新
* 对象存储,`BucketManager` `GetBucketInfo` 返回空间的备注信息
## 7.15.0
* 优化
* 表单上传 Put 方法的 PutExtra 参数,支持传入 nil
* Bucket 镜像源/配额方法内部请求使用 UC 域名
* BucketManager ListBucket 和 ListBucketContext 方法内部接口由 /v2/list 调用调整为 /list
* `BucketManager` `ListBucket``ListBucketContext` 方法内部接口由 /v2/list 调用调整为 /list
* 新增
* BucketManager 新增批量方法 BatchWithContext
* BucketManager 增加 Bucket 列举方法 ListFileWithContext
* `BucketManager` 新增批量方法 `BatchWithContext`
* `BucketManager` 增加 Bucket 列举方法 `ListFileWithContext`
## 7.14.0
* Go SDK 对七牛回调请求的鉴权验证函数支持 Qiniu 签名

@ -17,7 +17,7 @@ github.com/qiniu/go-sdk
在您的项目中的 `go.mod` 文件内添加这行代码
```
require github.com/qiniu/go-sdk/v7 v7.15.0
require github.com/qiniu/go-sdk/v7 v7.16.0
```
并且在项目中使用 `"github.com/qiniu/go-sdk/v7"` 引用 Qiniu Go SDK。

@ -5,7 +5,7 @@ import (
"strings"
)
const Version = "7.15.0"
const Version = "7.16.0"
const (
CONTENT_TYPE_JSON = "application/json"

@ -10,7 +10,9 @@ import (
"encoding/base64"
"errors"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"
"github.com/qiniu/go-sdk/v7/auth"
@ -328,6 +330,29 @@ func (m *BucketManager) Buckets(shared bool) (buckets []string, err error) {
return
}
// BucketsV4 获取该用户的指定区域内的空间信息,注意该 API 以分页形式返回 Bucket 列表
func (m *BucketManager) BucketsV4(input *BucketV4Input) (output BucketsV4Output, err error) {
if input == nil {
input = &BucketV4Input{}
}
reqURL := fmt.Sprintf("%s/buckets?apiVersion=v4", getUcHost(m.Cfg.UseHTTPS))
query := make(url.Values)
if input.Region != "" {
query.Add("region", input.Region)
}
if input.Limit > 0 {
query.Add("limit", strconv.FormatUint(input.Limit, 10))
}
if input.Marker != "" {
query.Add("marker", input.Marker)
}
if len(query) > 0 {
reqURL += "&" + query.Encode()
}
err = m.Client.CredentialedCall(context.Background(), m.Mac, auth.TokenQiniu, &output, http.MethodGet, reqURL, nil)
return
}
// DropBucket 删除七牛存储空间
func (m *BucketManager) DropBucket(bucketName string) (err error) {
reqURL := fmt.Sprintf("%s/drop/%s", getUcHost(m.Cfg.UseHTTPS), bucketName)

@ -0,0 +1,37 @@
package storage
import "time"
type (
// BucketV4 查询条件
BucketV4Input struct {
// 指定区域 ID如果传入空字符串则查询所有区域
Region string
// 最多获取的空间数,如果传入 0则查询 20 个空间
Limit uint64
// 获取下一页的标记
Marker string
}
// BucketV4 返回的空间信息
BucketsV4Output struct {
// 下页开始的 Marker
NextMarker string `json:"next_marker"`
// 列举是否被阶段,如果为 true则表示还有下一页
IsTruncated bool `json:"is_truncated"`
// 空间列表
Buckets []BucketV4Output `json:"buckets"`
}
// BucketV4 返回的空间信息
BucketV4Output struct {
// 空间名称
Name string `json:"name"`
// 空间区域 ID
Region string `json:"region"`
// 空间是否私有
Private bool `json:"private"`
// 空间创建时间
Ctime time.Time `json:"ctime"`
}
)

@ -7,6 +7,7 @@ import (
"net/url"
"strconv"
"strings"
"time"
"github.com/qiniu/go-sdk/v7/auth"
)
@ -83,6 +84,12 @@ type BucketInfo struct {
// 存储区域
Region string
// 空间备注信息
Remark string
// 空间创建时间
Ctime time.Time
}
// ReferAntiLeechConfig 是用户存储空间的Refer防盗链配置
@ -220,6 +227,16 @@ func (m *BucketManager) GetBucketInfo(bucketName string) (bucketInfo BucketInfo,
return
}
// SetRemark 设置空间备注信息
func (m *BucketManager) SetRemark(bucketName, remark string) (err error) {
reqURL := fmt.Sprintf("%s/buckets/%s?remark", getUcHost(m.Cfg.UseHTTPS), bucketName)
body := struct {
Remark string `json:"remark"`
}{Remark: remark}
err = m.Client.CredentialedCallWithJson(context.Background(), m.Mac, auth.TokenQiniu, nil, "PUT", reqURL, nil, body)
return
}
// BucketInfosForRegion 获取指定区域的该用户的所有bucketInfo信息
func (m *BucketManager) BucketInfosInRegion(region RegionID, statistics bool) (bucketInfos []BucketSummary, err error) {
reqURL := fmt.Sprintf("%s/v2/bucketInfos?region=%s&fs=%t", getUcHost(m.Cfg.UseHTTPS), string(region), statistics)

@ -328,6 +328,7 @@ func ParseDecimal128(s string) (Decimal128, error) {
return dErr(s)
}
// Parse the significand (i.e. the non-exponent part) as a big.Int.
bi, ok := new(big.Int).SetString(intPart+decPart, 10)
if !ok {
return dErr(s)
@ -360,6 +361,19 @@ func ParseDecimal128FromBigInt(bi *big.Int, exp int) (Decimal128, bool) {
q := new(big.Int)
r := new(big.Int)
// If the significand is zero, the logical value will always be zero, independent of the
// exponent. However, the loops for handling out-of-range exponent values below may be extremely
// slow for zero values because the significand never changes. Limit the exponent value to the
// supported range here to prevent entering the loops below.
if bi.Cmp(zero) == 0 {
if exp > MaxDecimal128Exp {
exp = MaxDecimal128Exp
}
if exp < MinDecimal128Exp {
exp = MinDecimal128Exp
}
}
for bigIntCmpAbs(bi, maxS) == 1 {
bi, _ = q.QuoRem(bi, ten, r)
if r.Cmp(zero) != 0 {

@ -34,6 +34,10 @@ type batchCursor interface {
// Close closes the cursor.
Close(context.Context) error
// The SetBatchSize method is a modifier function used to adjust the
// batch size of the cursor that implements it.
SetBatchSize(int32)
}
// changeStreamCursor is the interface implemented by batch cursors that also provide the functionality for retrieving

@ -314,6 +314,14 @@ func (c *Cursor) closeImplicitSession() {
}
}
// SetBatchSize sets the number of documents to fetch from the database with
// each iteration of the cursor's "Next" method. Note that some operations set
// an initial cursor batch size, so this setting only affects subsequent
// document batches fetched from the database.
func (c *Cursor) SetBatchSize(batchSize int32) {
c.bc.SetBatchSize(batchSize)
}
// BatchCursorFromCursor returns a driver.BatchCursor for the given Cursor. If there is no underlying
// driver.BatchCursor, nil is returned.
//

@ -8,4 +8,4 @@
package version // import "go.mongodb.org/mongo-driver/version"
// Driver is the current version of the driver.
var Driver = "v1.11.6"
var Driver = "v1.11.7"

@ -308,23 +308,37 @@ func (bc *BatchCursor) KillCursor(ctx context.Context) error {
}.Execute(ctx)
}
// calcGetMoreBatchSize calculates the number of documents to return in the
// response of a "getMore" operation based on the given limit, batchSize, and
// number of documents already returned. Returns false if a non-trivial limit is
// lower than or equal to the number of documents already returned.
func calcGetMoreBatchSize(bc BatchCursor) (int32, bool) {
gmBatchSize := bc.batchSize
// Account for legacy operations that don't support setting a limit.
if bc.limit != 0 && bc.numReturned+bc.batchSize >= bc.limit {
gmBatchSize = bc.limit - bc.numReturned
if gmBatchSize <= 0 {
return gmBatchSize, false
}
}
return gmBatchSize, true
}
func (bc *BatchCursor) getMore(ctx context.Context) {
bc.clearBatch()
if bc.id == 0 {
return
}
// Required for legacy operations which don't support limit.
numToReturn := bc.batchSize
if bc.limit != 0 && bc.numReturned+bc.batchSize >= bc.limit {
numToReturn = bc.limit - bc.numReturned
if numToReturn <= 0 {
err := bc.Close(ctx)
if err != nil {
bc.err = err
}
return
numToReturn, ok := calcGetMoreBatchSize(*bc)
if !ok {
if err := bc.Close(ctx); err != nil {
bc.err = err
}
return
}
bc.err = Operation{

@ -68,7 +68,8 @@ type Connection interface {
Close() error
ID() string
ServerConnectionID() *int32
ServerConnectionID() *int64
DriverConnectionID() uint64 // TODO(GODRIVER-2824): change type to int64.
Address() address.Address
Stale() bool
}
@ -157,12 +158,6 @@ const (
ConnectionPoolCleared
)
// ServerChanged returns true if the ProcessErrorResult indicates that the server changed from an SDAM perspective
// during a ProcessError() call.
func (p ProcessErrorResult) ServerChanged() bool {
return p != NoChange
}
// ErrorProcessor implementations can handle processing errors, which may modify their internal state.
// If this type is implemented by a Server, then Operation.Execute will call it's ProcessError
// method after it decodes a wire message.
@ -178,7 +173,7 @@ type ErrorProcessor interface {
type HandshakeInformation struct {
Description description.Server
SpeculativeAuthenticate bsoncore.Document
ServerConnectionID *int32
ServerConnectionID *int64
SaslSupportedMechs []string
}

@ -127,3 +127,8 @@ func (*ListCollectionsBatchCursor) projectNameElement(rawDoc bsoncore.Document)
filteredDoc = bsoncore.BuildDocument(filteredDoc, filteredElems)
return filteredDoc, nil
}
// SetBatchSize sets the batchSize for future getMores.
func (lcbc *ListCollectionsBatchCursor) SetBatchSize(size int32) {
lcbc.bc.SetBatchSize(size)
}

@ -321,6 +321,11 @@ func (m *MongoCrypt) RewrapDataKeyContext(filter []byte, opts *options.RewrapMan
return nil, m.createErrorFromStatus()
}
if opts.MasterKey != nil && opts.Provider == nil {
// Provider is nil, but MasterKey is set. This is an error.
return nil, fmt.Errorf("expected 'Provider' to be set to identify type of 'MasterKey'")
}
if opts.Provider != nil {
// If a provider has been specified, create an encryption key document for creating a data key or for rewrapping
// datakeys. If a new provider is not specified, then the filter portion of this logic returns the data as it

@ -11,6 +11,7 @@ import (
"context"
"errors"
"fmt"
"math"
"strconv"
"strings"
"sync"
@ -91,22 +92,40 @@ type startedInformation struct {
cmdName string
documentSequenceIncluded bool
connID string
serverConnID *int32
driverConnectionID uint64 // TODO(GODRIVER-2824): change type to int64.
serverConnID *int64
redacted bool
serviceID *primitive.ObjectID
}
// finishedInformation keeps track of all of the information necessary for monitoring success and failure events.
type finishedInformation struct {
cmdName string
requestID int32
response bsoncore.Document
cmdErr error
connID string
serverConnID *int32
startTime time.Time
redacted bool
serviceID *primitive.ObjectID
cmdName string
requestID int32
response bsoncore.Document
cmdErr error
connID string
driverConnectionID uint64 // TODO(GODRIVER-2824): change type to int64.
serverConnID *int64
startTime time.Time
redacted bool
serviceID *primitive.ObjectID
}
// convertInt64PtrToInt32Ptr will convert an int64 pointer reference to an int32 pointer
// reference. If the int64 value cannot be converted to int32 without causing
// an overflow, then this function will return nil.
func convertInt64PtrToInt32Ptr(i64 *int64) *int32 {
if i64 == nil {
return nil
}
if *i64 > math.MaxInt32 || *i64 < math.MinInt32 {
return nil
}
i32 := int32(*i64)
return &i32
}
// ResponseInfo contains the context required to parse a server response.
@ -552,6 +571,7 @@ func (op Operation) Execute(ctx context.Context) error {
// set extra data and send event if possible
startedInfo.connID = conn.ID()
startedInfo.driverConnectionID = conn.DriverConnectionID()
startedInfo.cmdName = op.getCommandName(startedInfo.cmd)
op.cmdName = startedInfo.cmdName
startedInfo.redacted = op.redactCommand(startedInfo.cmdName, startedInfo.cmd)
@ -574,13 +594,14 @@ func (op Operation) Execute(ctx context.Context) error {
}
finishedInfo := finishedInformation{
cmdName: startedInfo.cmdName,
requestID: startedInfo.requestID,
startTime: time.Now(),
connID: startedInfo.connID,
serverConnID: startedInfo.serverConnID,
redacted: startedInfo.redacted,
serviceID: startedInfo.serviceID,
cmdName: startedInfo.cmdName,
requestID: startedInfo.requestID,
startTime: time.Now(),
connID: startedInfo.connID,
driverConnectionID: startedInfo.driverConnectionID,
serverConnID: startedInfo.serverConnID,
redacted: startedInfo.redacted,
serviceID: startedInfo.serviceID,
}
// Check for possible context error. If no context error, check if there's enough time to perform a
@ -1704,7 +1725,7 @@ func (op Operation) publishStartedEvent(ctx context.Context, info startedInforma
CommandName: info.cmdName,
RequestID: int64(info.requestID),
ConnectionID: info.connID,
ServerConnectionID: info.serverConnID,
ServerConnectionID: convertInt64PtrToInt32Ptr(info.serverConnID),
ServiceID: info.serviceID,
}
op.CommandMonitor.Started(ctx, started)
@ -1732,7 +1753,7 @@ func (op Operation) publishFinishedEvent(ctx context.Context, info finishedInfor
RequestID: int64(info.requestID),
ConnectionID: info.connID,
DurationNanos: durationNanos,
ServerConnectionID: info.serverConnID,
ServerConnectionID: convertInt64PtrToInt32Ptr(info.serverConnID),
ServiceID: info.serviceID,
}

@ -240,7 +240,7 @@ func (h *Hello) GetHandshakeInformation(ctx context.Context, _ address.Address,
if speculativeAuthenticate, ok := h.res.Lookup("speculativeAuthenticate").DocumentOK(); ok {
info.SpeculativeAuthenticate = speculativeAuthenticate
}
if serverConnectionID, ok := h.res.Lookup("connectionId").Int32OK(); ok {
if serverConnectionID, ok := h.res.Lookup("connectionId").AsInt64OK(); ok {
info.ServerConnectionID = &serverConnectionID
}
// Cast to bson.Raw to lookup saslSupportedMechs to avoid converting from bsoncore.Value to bson.RawValue for the

@ -86,7 +86,8 @@ type LoadBalancedTransactionConnection interface {
Description() description.Server
Close() error
ID() string
ServerConnectionID() *int32
ServerConnectionID() *int64
DriverConnectionID() uint64 // TODO(GODRIVER-2824): change type to int64.
Address() address.Address
Stale() bool

@ -70,12 +70,14 @@ type connection struct {
currentlyStreaming bool
connectContextMutex sync.Mutex
cancellationListener cancellationListener
serverConnectionID *int32 // the server's ID for this client's connection
serverConnectionID *int64 // the server's ID for this client's connection
// pool related fields
pool *pool
poolID uint64
generation uint64
pool *pool
// TODO(GODRIVER-2824): change driverConnectionID type to int64.
driverConnectionID uint64
generation uint64
}
// newConnection handles the creation of a connection. It does not connect the connection.
@ -105,6 +107,12 @@ func newConnection(addr address.Address, opts ...ConnectionOption) *connection {
return c
}
// DriverConnectionID returns the driver connection ID.
// TODO(GODRIVER-2824): change return type to int64.
func (c *connection) DriverConnectionID() uint64 {
return c.driverConnectionID
}
// setGenerationNumber sets the connection's generation number if a callback has been provided to do so in connection
// configuration.
func (c *connection) setGenerationNumber() {
@ -527,7 +535,7 @@ func (c *connection) ID() string {
return c.id
}
func (c *connection) ServerConnectionID() *int32 {
func (c *connection) ServerConnectionID() *int64 {
return c.serverConnectionID
}
@ -708,7 +716,7 @@ func (c *Connection) ID() string {
}
// ServerConnectionID returns the server connection ID of this connection.
func (c *Connection) ServerConnectionID() *int32 {
func (c *Connection) ServerConnectionID() *int64 {
if c.connection == nil {
return nil
}
@ -794,6 +802,12 @@ func (c *Connection) unpin(reason string) error {
return nil
}
// DriverConnectionID returns the driver connection ID.
// TODO(GODRIVER-2824): change return type to int64.
func (c *Connection) DriverConnectionID() uint64 {
return c.connection.DriverConnectionID()
}
func configureTLS(ctx context.Context,
tlsConnSource tlsConnectionSource,
nc net.Conn,

@ -454,7 +454,7 @@ func (p *pool) checkOut(ctx context.Context) (conn *connection, err error) {
p.monitor.Event(&event.PoolEvent{
Type: event.GetSucceeded,
Address: p.address.String(),
ConnectionID: w.conn.poolID,
ConnectionID: w.conn.driverConnectionID,
})
}
return w.conn, nil
@ -483,7 +483,7 @@ func (p *pool) checkOut(ctx context.Context) (conn *connection, err error) {
p.monitor.Event(&event.PoolEvent{
Type: event.GetSucceeded,
Address: p.address.String(),
ConnectionID: w.conn.poolID,
ConnectionID: w.conn.driverConnectionID,
})
}
return w.conn, nil
@ -539,14 +539,14 @@ func (p *pool) removeConnection(conn *connection, reason string) error {
}
p.createConnectionsCond.L.Lock()
_, ok := p.conns[conn.poolID]
_, ok := p.conns[conn.driverConnectionID]
if !ok {
// If the connection has been removed from the pool already, exit without doing any
// additional state changes.
p.createConnectionsCond.L.Unlock()
return nil
}
delete(p.conns, conn.poolID)
delete(p.conns, conn.driverConnectionID)
// Signal the createConnectionsCond so any goroutines waiting for a new connection slot in the
// pool will proceed.
p.createConnectionsCond.Signal()
@ -563,7 +563,7 @@ func (p *pool) removeConnection(conn *connection, reason string) error {
p.monitor.Event(&event.PoolEvent{
Type: event.ConnectionClosed,
Address: p.address.String(),
ConnectionID: conn.poolID,
ConnectionID: conn.driverConnectionID,
Reason: reason,
})
}
@ -584,7 +584,7 @@ func (p *pool) checkIn(conn *connection) error {
if p.monitor != nil {
p.monitor.Event(&event.PoolEvent{
Type: event.ConnectionReturned,
ConnectionID: conn.poolID,
ConnectionID: conn.driverConnectionID,
Address: conn.addr.String(),
})
}
@ -817,8 +817,8 @@ func (p *pool) createConnections(ctx context.Context, wg *sync.WaitGroup) {
conn := newConnection(p.address, p.connOpts...)
conn.pool = p
conn.poolID = atomic.AddUint64(&p.nextID, 1)
p.conns[conn.poolID] = conn
conn.driverConnectionID = atomic.AddUint64(&p.nextID, 1)
p.conns[conn.driverConnectionID] = conn
return w, conn, true
}
@ -833,7 +833,7 @@ func (p *pool) createConnections(ctx context.Context, wg *sync.WaitGroup) {
p.monitor.Event(&event.PoolEvent{
Type: event.ConnectionCreated,
Address: p.address.String(),
ConnectionID: conn.poolID,
ConnectionID: conn.driverConnectionID,
})
}
@ -862,7 +862,7 @@ func (p *pool) createConnections(ctx context.Context, wg *sync.WaitGroup) {
p.monitor.Event(&event.PoolEvent{
Type: event.ConnectionReady,
Address: p.address.String(),
ConnectionID: conn.poolID,
ConnectionID: conn.driverConnectionID,
})
}

@ -24,6 +24,7 @@ import (
)
const minHeartbeatInterval = 500 * time.Millisecond
const wireVersion42 = 8 // Wire version for MongoDB 4.2
// Server state constants.
const (
@ -294,6 +295,8 @@ func (s *Server) ProcessHandshakeError(err error, startingGenerationNumber uint6
return
}
// Unwrap any connection errors. If there is no wrapped connection error, then the error should
// not result in any Server state change (e.g. a command error from the database).
wrappedConnErr := unwrapConnectionError(err)
if wrappedConnErr == nil {
return
@ -384,27 +387,58 @@ func getWriteConcernErrorForProcessing(err error) (*driver.WriteConcernError, bo
// ProcessError handles SDAM error handling and implements driver.ErrorProcessor.
func (s *Server) ProcessError(err error, conn driver.Connection) driver.ProcessErrorResult {
// ignore nil error
// Ignore nil errors.
if err == nil {
return driver.NoChange
}
// Ignore errors from stale connections because the error came from a previous generation of the
// connection pool. The root cause of the error has aleady been handled, which is what caused
// the pool generation to increment. Processing errors for stale connections could result in
// handling the same error root cause multiple times (e.g. a temporary network interrupt causing
// all connections to the same server to return errors).
if conn.Stale() {
return driver.NoChange
}
// Must hold the processErrorLock while updating the server description and clearing the pool.
// Not holding the lock leads to possible out-of-order processing of pool.clear() and
// pool.ready() calls from concurrent server description updates.
s.processErrorLock.Lock()
defer s.processErrorLock.Unlock()
// ignore stale error
if conn.Stale() {
return driver.NoChange
// Get the wire version and service ID from the connection description because they will never
// change for the lifetime of a connection and can possibly be different between connections to
// the same server.
connDesc := conn.Description()
wireVersion := connDesc.WireVersion
serviceID := connDesc.ServiceID
// Get the topology version from the Server description because the Server description is
// updated by heartbeats and errors, so typically has a more up-to-date topology version.
serverDesc := s.desc.Load().(description.Server)
topologyVersion := serverDesc.TopologyVersion
// We don't currently update the Server topology version when we create new application
// connections, so it's possible for a connection's topology version to be newer than the
// Server's topology version. Pick the "newest" of the two topology versions.
// Technically a nil topology version on a new database response should be considered a new
// topology version and replace the Server's topology version. However, we don't know if the
// connection's topology version is based on a new or old database response, so we ignore a nil
// topology version on the connection for now.
//
// TODO(GODRIVER-2841): Remove this logic once we set the Server description when we create
// TODO application connections because then the Server's topology version will always be the
// TODO latest known.
if tv := connDesc.TopologyVersion; tv != nil && topologyVersion.CompareToIncoming(tv) < 0 {
topologyVersion = tv
}
// Invalidate server description if not primary or node recovering error occurs.
// These errors can be reported as a command error or a write concern error.
desc := conn.Description()
if cerr, ok := err.(driver.Error); ok && (cerr.NodeIsRecovering() || cerr.NotPrimary()) {
// ignore stale error
if desc.TopologyVersion.CompareToIncoming(cerr.TopologyVersion) >= 0 {
// Ignore errors that came from when the database was on a previous topology version.
if topologyVersion.CompareToIncoming(cerr.TopologyVersion) >= 0 {
return driver.NoChange
}
@ -414,16 +448,16 @@ func (s *Server) ProcessError(err error, conn driver.Connection) driver.ProcessE
res := driver.ServerMarkedUnknown
// If the node is shutting down or is older than 4.2, we synchronously clear the pool
if cerr.NodeIsShuttingDown() || desc.WireVersion == nil || desc.WireVersion.Max < 8 {
if cerr.NodeIsShuttingDown() || wireVersion == nil || wireVersion.Max < wireVersion42 {
res = driver.ConnectionPoolCleared
s.pool.clear(err, desc.ServiceID)
s.pool.clear(err, serviceID)
}
return res
}
if wcerr, ok := getWriteConcernErrorForProcessing(err); ok {
// ignore stale error
if desc.TopologyVersion.CompareToIncoming(wcerr.TopologyVersion) >= 0 {
// Ignore errors that came from when the database was on a previous topology version.
if topologyVersion.CompareToIncoming(wcerr.TopologyVersion) >= 0 {
return driver.NoChange
}
@ -433,9 +467,9 @@ func (s *Server) ProcessError(err error, conn driver.Connection) driver.ProcessE
res := driver.ServerMarkedUnknown
// If the node is shutting down or is older than 4.2, we synchronously clear the pool
if wcerr.NodeIsShuttingDown() || desc.WireVersion == nil || desc.WireVersion.Max < 8 {
if wcerr.NodeIsShuttingDown() || wireVersion == nil || wireVersion.Max < wireVersion42 {
res = driver.ConnectionPoolCleared
s.pool.clear(err, desc.ServiceID)
s.pool.clear(err, serviceID)
}
return res
}
@ -457,7 +491,7 @@ func (s *Server) ProcessError(err error, conn driver.Connection) driver.ProcessE
// monitoring check. The check is cancelled last to avoid a post-cancellation reconnect racing with
// updateDescription.
s.updateDescription(description.NewServerFromError(s.address, err, nil))
s.pool.clear(err, desc.ServiceID)
s.pool.clear(err, serviceID)
s.cancelCheck()
return driver.ConnectionPoolCleared
}

@ -8,7 +8,7 @@ github.com/aliyun/aliyun-oss-go-sdk/oss
## explicit; go 1.16
github.com/allegro/bigcache/v3
github.com/allegro/bigcache/v3/queue
# github.com/baidubce/bce-sdk-go v0.9.150
# github.com/baidubce/bce-sdk-go v0.9.151
## explicit; go 1.11
github.com/baidubce/bce-sdk-go/auth
github.com/baidubce/bce-sdk-go/bce
@ -103,7 +103,7 @@ github.com/go-playground/locales/zh
# github.com/go-playground/universal-translator v0.18.1
## explicit; go 1.18
github.com/go-playground/universal-translator
# github.com/go-playground/validator/v10 v10.14.0
# github.com/go-playground/validator/v10 v10.14.1
## explicit; go 1.18
github.com/go-playground/validator/v10
github.com/go-playground/validator/v10/translations/en
@ -272,7 +272,7 @@ github.com/pelletier/go-toml/v2/unstable
# github.com/pkg/errors v0.9.1
## explicit
github.com/pkg/errors
# github.com/qiniu/go-sdk/v7 v7.15.0
# github.com/qiniu/go-sdk/v7 v7.16.0
## explicit; go 1.14
github.com/qiniu/go-sdk/v7
github.com/qiniu/go-sdk/v7/auth
@ -387,7 +387,7 @@ github.com/youmark/pkcs8
# github.com/yusufpapurcu/wmi v1.2.3
## explicit; go 1.16
github.com/yusufpapurcu/wmi
# go.mongodb.org/mongo-driver v1.11.6
# go.mongodb.org/mongo-driver v1.11.7
## explicit; go 1.13
go.mongodb.org/mongo-driver/bson
go.mongodb.org/mongo-driver/bson/bsoncodec

Loading…
Cancel
Save