本文整理匯總了Golang中github.com/pavel-paulau/gateload/api.SyncGatewayClient.AddUser方法的典型用法代碼示例。如果您正苦於以下問題:Golang SyncGatewayClient.AddUser方法的具體用法?Golang SyncGatewayClient.AddUser怎麽用?Golang SyncGatewayClient.AddUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pavel-paulau/gateload/api.SyncGatewayClient
的用法示例。
在下文中一共展示了SyncGatewayClient.AddUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
var config workload.Config
workload.ReadConfig(&config)
s := seriesly.SerieslyClient{}
s.Init(config.SerieslyHostname, "sync_latency"+config.SerieslyDatabase)
c := api.SyncGatewayClient{}
c.Init(config.Hostname, config.Database)
user := api.UserAuth{"collector", "password", []string{"stats"}}
c.AddUser(user.Name, user)
session := api.Session{Name: user.Name, TTL: 2592000}
cookie := c.CreateSession(user.Name, session)
c.AddCookie(&cookie)
activeSamplers = 0
for doc := range workload.DocIterator(0, DocsPerUser, config.DocSize, "stats") {
if activeSamplers < MaxSamplers {
activeSamplers++
go measureLatency(&c, &s, doc)
}
time.Sleep(time.Duration(1000) * time.Millisecond)
}
}
示例2: createSession
func createSession(admin *api.SyncGatewayClient, user workload.User, config workload.Config) http.Cookie {
userMeta := api.UserAuth{Name: user.Name, Password: "password", AdminChannels: []string{user.Channel}}
admin.AddUser(user.Name, userMeta)
session := api.Session{Name: user.Name, TTL: 2592000} // 1 month
return admin.CreateSession(user.Name, session)
}