当前位置: 首页>>代码示例>>Golang>>正文


Golang Conn.SubAddConfiguration方法代码示例

本文整理汇总了Golang中github.com/zond/god/client.Conn.SubAddConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Golang Conn.SubAddConfiguration方法的具体用法?Golang Conn.SubAddConfiguration怎么用?Golang Conn.SubAddConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/zond/god/client.Conn的用法示例。


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

示例1: handleUDP

func handleUDP(ch chan []byte, c *client.Conn, queueSize *int32) {
	var err error
	var mess common.Message
	for bytes := range ch {
		err = json.Unmarshal(bytes, &mess)
		if err == nil {
			if mess.Type == common.View {
				// Create a byte encoded timestamp for now
				t := time.Now().UnixNano()
				encT := godCommon.EncodeInt64(t)
				// Make the object id active
				c.SubPut(activeObjectsKey, []byte(mess.Object), encT)
				// Create a key for the views of this user
				vKey := uViewsKey(mess.User)
				// Make sure the sub tree is mirrored
				c.SubAddConfiguration(vKey, "mirrored", "yes")
				// Log this view
				c.SubPut(vKey, []byte(mess.Object), encT)
				// Create an encoded timestamp for something older than timeout
				tooOld := time.Now().Add(-time.Hour * 24 * time.Duration((*timeout))).UnixNano()
				// Delete all viewed entries with timestamp older than that
				for _, item := range c.MirrorSlice(vKey, nil, godCommon.EncodeInt64(tooOld), true, true) {
					c.SubDel(vKey, item.Value)
				}
				// Delete all active entries with timestamp older than that
				for _, item := range c.MirrorSlice(activeObjectsKey, nil, godCommon.EncodeInt64(tooOld), true, true) {
					c.SubDel(activeObjectsKey, item.Value)
				}
			} else if mess.Type == common.Like {
				// Record the liked object under user
				c.SubPut(uLikesKey(mess.User), []byte(mess.Object), godCommon.EncodeFloat64(mess.Weight))
				// Record the liker under the liked object
				c.SubPut(oLikesKey(mess.Object), []byte(mess.User), nil)
				if !mess.DontActivate {
					// Make the object id active
					c.SubPut(activeObjectsKey, []byte(mess.Object), nil)
				}
				// Create an encoded timestamp for something older than timeout
				tooOld := time.Now().Add(-time.Hour * 24 * time.Duration((*timeout))).UnixNano()
				// Delete all active entries with timestamp older than that
				for _, item := range c.MirrorSlice(activeObjectsKey, nil, godCommon.EncodeInt64(tooOld), true, true) {
					c.SubDel(activeObjectsKey, item.Value)
				}
			} else if mess.Type == common.Deactivate {
				// Remote the object id from the active objects
				c.SubDel(activeObjectsKey, []byte(mess.Object))
			}
		} else {
			fmt.Printf("When parsing %v: %v\n", string(bytes), err)
		}
		atomic.AddInt32(queueSize, -1)
	}
}
开发者ID:zond,项目名称:commendable,代码行数:53,代码来源:commendable_server.go

示例2: subConfigure

func subConfigure(conn *client.Conn, args []string) {
	conn.SubAddConfiguration([]byte(args[1]), args[2], args[3])
}
开发者ID:rrudduck,项目名称:golang-stuff,代码行数:3,代码来源:god_cli.go


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