首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mongo-go-driver的clientOptions的默认值是什么?

mongo-go-driver的clientOptions的默认值是什么?
EN

Stack Overflow用户
提问于 2019-09-07 05:17:27
回答 2查看 882关注 0票数 1

我正在尝试搜索mongo-go-driver的clientOptions的默认值。

我正在尝试通过以下方式启动新的客户端:

代码语言:javascript
复制
        opts := options.ClientOptions{}
    opts.ApplyURI(connectionURI)
    sharedConnection, err = mongo.NewClient(&opts)

我想知道像ConnectTimeout,MaxPoolSize,MaxConnIdleTime这样的clientOptions的默认值是多少。

代码语言:javascript
复制
   type ClientOptions struct {
    ConnectTimeout         *time.Duration
    Compressors            []string
    Dialer                 ContextDialer
    HeartbeatInterval      *time.Duration
    LocalThreshold         *time.Duration
    MaxConnIdleTime        *time.Duration
    MaxPoolSize            *uint16
    Monitor                *event.CommandMonitor
    ReadConcern            *readconcern.ReadConcern
    ReadPreference         *readpref.ReadPref
    Registry               *bsoncodec.Registry
    RetryWrites            *bool
    ServerSelectionTimeout *time.Duration
    Direct                 *bool
    SocketTimeout          *time.Duration
    TLSConfig              *tls.Config
    WriteConcern           *writeconcern.WriteConcern
    ZlibLevel              *int
   }
EN

回答 2

Stack Overflow用户

发布于 2019-09-11 14:05:30

以下默认值基于mongo-go-driver v1.1.x和MongoDB server v4.2。你还可以在MongoDB driver specs上找到更多信息/行为。

代码语言:javascript
复制
ConnectTimeout         30 * time.Second
Compressors            nil (compression will not be used)
Dialer                 net.Dialer with a 300 second keepalive time
HeartbeatInterval      10 * time.Second
LocalThreshold         15 * time.Millisecond
MaxConnIdleTime        nil (no limit)
MaxPoolSize            100
Monitor                nil
ReadConcern            nil (server default `local`)
ReadPreference         readpref.Primary()
Registry               bson.DefaultRegistry
RetryWrites            true
ServerSelectionTimeout 30 * time.Second
Direct                 false
SocketTimeout          nil (infinite)
TLSConfig              nil
WriteConcern           nil (server default `w:1`)
ZlibLevel              6 (if zlib compression enabled)
票数 1
EN

Stack Overflow用户

发布于 2019-09-07 06:42:39

如果没有流来设置默认值,那么它将设置为零值。零值是指声明变量且未显式初始化时,将使用默认值为其分配存储空间

  1. ConnectTimeout --> 0
  2. MaxConnIdleTime,数据类型默认值=0sb.
  3. MaxPoolSize --> uint16,数据类型默认值=0
  4. MaxConnIdleTime --> time.Duration,数据类型默认值= 0s

另一个:

  1. bool -->默认值为false
  2. string -->默认值为""
  3. int ->默认值为0
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57828646

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档