亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

mongo-go-driver 的 clientOptions 默認值是多少?

mongo-go-driver 的 clientOptions 默認值是多少?

Go
白衣非少年 2023-07-17 17:58:17
我試圖搜索 mongo-go-driver 的 clientOptions 的默認值。我正在嘗試通過以下方式啟動新客戶:        opts := options.ClientOptions{}    opts.ApplyURI(connectionURI)    sharedConnection, err = mongo.NewClient(&opts)我想知道 ConnectTimeout、MaxPoolSize、MaxConnIdleTime 等少數 clientOptions 的默認值是什么。   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   }
查看完整描述

2 回答

?
慕標5832272

TA貢獻1966條經驗 獲得超4個贊

以下默認基于mongo-go-driverv1.1.x 和 MongoDB 服務器 v4.2。

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)


查看完整回答
反對 回復 2023-07-17
?
慕姐4208626

TA貢獻1852條經驗 獲得超7個贊

如果沒有流量設置默認值,則它將設置為零值。零值是當一個變量被聲明并且沒有顯式初始化時,它將被分配一個帶有默認值的存儲空間

  1. ConnectTimeout --> time.Duration,數據類型默認值 = 0s b.

  2. MaxPoolSize --> uint16,數據類型默認值 = 0

  3. MaxConnIdleTime --> time.Duration,數據類型默認值 = 0s

其他 :

  1. bool --> 默認值為 false

  2. 字符串 --> 默認值為“”

  3. int ---> 默認值為 0


查看完整回答
反對 回復 2023-07-17
  • 2 回答
  • 0 關注
  • 228 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號