當前位置: 首頁>>代碼示例>>Golang>>正文


Golang SyncGatewayClient.Init方法代碼示例

本文整理匯總了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()
	}
}
開發者ID:pavel-paulau,項目名稱:gateload,代碼行數:32,代碼來源:main.go

示例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)
	}
}
開發者ID:pavel-paulau,項目名稱:go-cbagent,代碼行數:27,代碼來源:main.go

示例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)
	}
}
開發者ID:pavel-paulau,項目名稱:gateload,代碼行數:12,代碼來源:main.go


注:本文中的github.com/pavel-paulau/gateload/api.SyncGatewayClient.Init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。