国产chinesehdxxxx野外,国产av无码专区亚洲av琪琪,播放男人添女人下边视频,成人国产精品一区二区免费看,chinese丰满人妻videos

go-zero rpc配置

2022-04-25 17:47 更新

rpc配置

rpc配置控制著一個rpc服務(wù)的各種功能,包含但不限于監(jiān)聽地址,etcd配置,超時,熔斷配置等,下面我們以一個常見的rpc服務(wù)配置來進行說明。

配置說明

Config struct {
    zrpc.RpcServerConf
    CacheRedis         cache.CacheConf // redis緩存配置,詳情見api配置說明,這里不贅述
    Mysql struct { // mysql數(shù)據(jù)庫訪問配置,詳情見api配置說明,這里不贅述
        DataSource string
    }
}

zrpc.RpcServerConf

RpcServerConf struct {
    service.ServiceConf // 服務(wù)配置,詳情見api配置說明,這里不贅述
    ListenOn      string // rpc監(jiān)聽地址和端口,如:127.0.0.1:8888
    Etcd          discov.EtcdConf    `json:",optional"` // etcd相關(guān)配置
    Auth          bool               `json:",optional"` // 是否開啟Auth,如果是則Redis為必填
    Redis         redis.RedisKeyConf `json:",optional"` // Auth驗證
    StrictControl bool               `json:",optional"` // 是否Strict模式,如果是則遇到錯誤是Auth失敗,否則可以認為成功
    // pending forever is not allowed
    // never set it to 0, if zero, the underlying will set to 2s automatically
    Timeout      int64 `json:",default=2000"` // 超時控制,單位:毫秒
    CpuThreshold int64 `json:",default=900,range=[0:1000]"` cpu降載閾值,默認900,可允許設(shè)置范圍0到1000
}

discov.EtcdConf

type EtcdConf struct {
    Hosts []string // etcd host數(shù)組
    Key   string // rpc注冊key
}

redis.RedisKeyConf

RedisConf struct {
    Host string // redis 主機
    Type string `json:",default=node,options=node|cluster"` // redis類型
    Pass string `json:",optional"` // redis密碼
}

RedisKeyConf struct {
    RedisConf
    Key string `json:",optional"` // 驗證key
}


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號