• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang module_state2.State类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中www/baidu/com/golang-lib/module_state2.State的典型用法代码示例。如果您正苦于以下问题:Golang State类的具体用法?Golang State怎么用?Golang State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了State类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestBNSRedisPool

func TestBNSRedisPool() {
	bnsName := "group.proxy-graph-f2e-new.OPENSTORAGE.all" // bns of redis server
	maxIdle := 100                                         // max Idle connection
	connectTimeout := 100                                  // connection timeout in ms
	readTimeout := 100                                     // read redis server timeout in ms
	writeTimeout := 100                                    // write redis server timeout in ms
	var state module_state2.State
	state.Init()
	state.Inc("counter", 1)
	state.Set("state", "OK")
	state.SetNum("cap", 100)
	redisClient := redis_bns.NewRedisClient(bnsName, maxIdle, connectTimeout, readTimeout, writeTimeout, &state)
	//conn := redisClient.GetRedisConn()
	//app, err := conn.Do("hmget", "voiceplatform_792_info", "app", "qps")
	//defer conn.Close()
	now := time.Now()
	nanos := now.UnixNano()
	for i := 0; i < 5000; i++ {
		//fmt.Print(i)
		//fmt.Print(",")

		redisClient.Get("voiceplatform_792_qps")
	}
	now = time.Now()
	end := now.UnixNano()
	fmt.Println("time", (end - nanos))
	//app, err := redis.String(app, nil)
	//fmt.Println(app, err, yy)
}
开发者ID:qiangmzsx,项目名称:golang,代码行数:29,代码来源:bnsredis.go


示例2: TestIncSucess

func TestIncSucess(t *testing.T) {
	var state module_state2.State
	state.Init()
	s, _ := NewSyncState(&state, &SyncStateParams{"totalCountKey", "errCountKey",
		"sucessCountKey", "lastUpdateTimeKey"})

	s.IncSucess()
	if s.state.GetCounter("sucessCountKey") != 1 {
		t.Errorf("s.state[sucessCountKey] should be 1: %d", s.state.GetCounter("sucessCountKey"))
	}
}
开发者ID:qiangmzsx,项目名称:golang,代码行数:11,代码来源:sync_state_test.go


示例3: TestNewBnsSyncTable

// test NewBnsSyncTable
func TestNewBnsSyncTable(t *testing.T) {
	var state module_state2.State
	state.Init()

	_, err := NewBnsSyncTable("gslb-scheduler.bfe.all", 5, "./test_data/", &state,
		&SyncStateParams{"totalCountKey", "errCountKey", "sucessCountKey", "lastUpdateTimeKey"})
	if err != nil {
		t.Errorf("unexpected err:%v", err)
		return
	}

}
开发者ID:qiangmzsx,项目名称:golang,代码行数:13,代码来源:bns_sync_table_test.go


示例4: TestSetLastUpdate

func TestSetLastUpdate(t *testing.T) {
	var state module_state2.State
	state.Init()
	s, _ := NewSyncState(&state, &SyncStateParams{"totalCountKey", "errCountKey",
		"sucessCountKey", "lastUpdateTimeKey"})

	s.SetLastUpdate("2015/03/04 19:33:33")
	if s.state.GetState("lastUpdateTimeKey") != "2015/03/04 19:33:33" {
		t.Errorf("s.state[lastUpdateTimeKey] should be '2015/03/04 19:33:33': %s",
			s.state.GetState("lastUpdateTimeKey"))
	}
}
开发者ID:qiangmzsx,项目名称:golang,代码行数:12,代码来源:sync_state_test.go


示例5: GetRedisCilent

/**
*  获取RedisClient实例,但是不能使用单例
**/
func GetRedisCilent() *redis_bns.RedisClient {
	redisIdc := beego.AppConfig.DefaultString("redisIdc", "bj")
	bnsName := beego.AppConfig.DefaultString("redis_bnsName", "group.proxy-graph-f2e-new.OPENSTORAGE.all")
	maxIdle := beego.AppConfig.DefaultInt("redis_maxIdle", 100)              // max Idle connection
	connectTimeout := beego.AppConfig.DefaultInt("redis_connectTimeout", 60) // connection timeout in ms
	readTimeout := beego.AppConfig.DefaultInt("redis_readTimeout", 100)      // read redis server timeout in ms
	writeTimeout := beego.AppConfig.DefaultInt("redis_writeTimeout", 100)    // write redis server timeout in ms
	idleTimeout := beego.AppConfig.DefaultInt("redis_idleTimeout", 60000)
	var state module_state2.State
	state.Init()
	beego.Notice("GetRedisCilent")
	redisClient := redis_bns.NewRedisClient(bnsName, redisIdc, maxIdle, connectTimeout, readTimeout, writeTimeout, idleTimeout, &state)
	return redisClient
}
开发者ID:qiangmzsx,项目名称:golang,代码行数:17,代码来源:util.go


示例6: TestBNSRedisGet

func TestBNSRedisGet() {
	bnsName := "group.proxy-graph-f2e-new.OPENSTORAGE.all" // bns of redis server
	maxIdle := 100                                         // max Idle connection
	connectTimeout := 50                                   // connection timeout in ms
	readTimeout := 100                                     // read redis server timeout in ms
	writeTimeout := 100                                    // write redis server timeout in ms
	idleTimeout := 60000
	var state module_state2.State
	state.Init()
	//	state.Inc("counter", 1)
	//	state.Set("state", "OK")
	//	state.SetNum("cap", 100)
	redisClient := redis_bns.NewRedisClient(bnsName, maxIdle, connectTimeout, readTimeout, writeTimeout, idleTimeout, &state)
	//	conn := redisClient.GetRedisConn()
	//	arg := []interface{}{"voiceplatform_7921_qps", "8"}
	//	fmt.Println("len:", len(arg))
	//	app, err := conn.Do("SET", arg)
	//	if err != nil {
	//		fmt.Println(err)
	//	}
	//	app, err = conn.Do("GET", "voiceplatform_792_info")
	//	if err != nil {
	//		fmt.Println(err)
	//	}
	//	defer conn.Close()

	//////////////////////////
	//fmt.Println(redisClient)
	arg := []interface{}{"SET", "voiceplatform_7921_qps", "8"}
	fmt.Println("len:", len(arg))
	redisClient.Do("HMSET", "voiceplatform_792_info", "app", "ec_jiaocuo,cq_duolun", "qps", "10000", "flowCount", "1000000000")
	app, err := redisClient.Do(arg[0].(string), arg[1:]...)
	err = redisClient.Send("SET", "voiceplatform_7921_qps", "8")
	if err != nil {
		fmt.Println(err)
	}
	//app, err = redis.String(redisClient.Do("GET", "voiceplatform_792_qps"))

	app, err = redis.Strings(redisClient.Do("HMGET", "voiceplatform_792_info", "app", "qps", "flowCount"))
	//app, err = redis.Strings(redisClient.Do("HMGET", "voiceplatform_7921_info", "app", "qps", "flowCount"))
	if err != nil {
		fmt.Println(err)
	}

	fmt.Println(app, err)
}
开发者ID:qiangmzsx,项目名称:golang,代码行数:46,代码来源:bnsredis.go


示例7: TestBNSRedis

func TestBNSRedis(t *testing.T) {
	bnsName := "group.proxy-graph-f2e-new.OPENSTORAGE.all" // bns of redis server
	maxIdle := 100                                         // max Idle connection
	connectTimeout := 100                                  // connection timeout in ms
	readTimeout := 100                                     // read redis server timeout in ms
	writeTimeout := 100                                    // write redis server timeout in ms
	var state module_state2.State
	state.Init()
	state.Inc("counter", 1)
	state.Set("state", "OK")
	state.SetNum("cap", 100)
	redisClient := redis_bns.NewRedisClient(bnsName, maxIdle, connectTimeout, readTimeout, writeTimeout, &state)
	//conn := redisClient.GetRedisConn()
	//app, err := conn.Do("hmget", "voiceplatform_792_info", "app", "qps")
	//defer conn.Close()
	app, yy := redisClient.Get("voiceplatform_792_qps")
	app, err := redis.String(app, nil)
	fmt.Println(app, err, yy)
}
开发者ID:qiangmzsx,项目名称:golang,代码行数:19,代码来源:bnsredis_test.go


示例8: TestModelState

func TestModelState(t *testing.T) {
	var state module_state2.State

	state.Init()

	state.Inc("counter", 1)
	state.Set("state", "OK")
	state.SetNum("cap", 100)
	fmt.Println(state)
	stateData := state.GetAll()
	fmt.Println(stateData)
}
开发者ID:qiangmzsx,项目名称:golang,代码行数:12,代码来源:bnsredis_test.go



注:本文中的www/baidu/com/golang-lib/module_state2.State类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang operation.Operation类代码示例发布时间:2022-05-28
下一篇:
Golang worker.Tuple类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap