本文整理汇总了Golang中github.com/pavel-paulau/gateload/api.SyncGatewayClient.Init方法的典型用法代码示例。如果您正苦于以下问题:Golang SyncGatewayClient.Init方法的具体用法?Golang SyncGatewayClient.Init怎么用?Golang SyncGatewayClient.Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pavel-paulau/gateload/api.SyncGatewayClient
的用法示例。
在下文中一共展示了SyncGatewayClient.Init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
var config workload.Config
workload.ReadConfig(&config)
admin := api.SyncGatewayClient{}
admin.Init(config.Hostname, config.Database)
users := [][]interface{}{}
for user := range workload.UserIterator(config.NumPullers, config.NumPushers) {
cookie := createSession(&admin, user, config)
users = append(users, []interface{}{user, cookie})
}
rampUpDelay := config.RampUpIntervalMs / (config.NumPullers + config.NumPushers)
rampUpDelayMs := time.Duration(rampUpDelay) * time.Millisecond
wg := sync.WaitGroup{}
for _, user := range users {
wg := sync.WaitGroup{}
go runUser(user[0].(workload.User), config, user[1].(http.Cookie), &wg)
wg.Add(1)
time.Sleep(rampUpDelayMs)
}
if config.RunTimeMs > 0 {
time.Sleep(time.Duration(config.RunTimeMs-config.RampUpIntervalMs) * time.Millisecond)
log.Println("Shutting down clients")
} else {
wg.Wait()
}
}
示例2: 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)
}
}
示例3: runUser
func runUser(user workload.User, config workload.Config, cookie http.Cookie, wg *sync.WaitGroup) {
c := api.SyncGatewayClient{}
c.Init(config.Hostname, config.Database)
c.AddCookie(&cookie)
log.Printf("Starting new %s (%s)", user.Type, user.Name)
if user.Type == "pusher" {
go workload.RunPusher(&c, user.Channel, config.DocSize, user.SeqId, config.SleepTimeMs, wg)
} else {
go workload.RunPuller(&c, user.Channel, user.Name, wg)
}
}