Пример #1
0
		pull, err := nano.NewPullSocket()
		gom.Expect(err).Should(gom.BeNil())
		pull.SetRecvTimeout(6 * time.Second)
		pull.SetRecvBuffer(1000)
		pull.Bind("ipc:///tmp/goreportertest.ipc")
		key := "key"
		rep.RegisterStat(key)
		rep.RegisterStatWIndex(key, "index")
		rep.AddStat(key, 2)
		rep.AddStat(key, 2)
		rep.AddStatWIndex(key, 2, "index")
		rep.AddStatWIndex(key, 2, "index")
		msg, err := pull.Recv(0)
		gom.Expect(err).Should(gom.BeNil())
		stats := new(protoStat.ProtoStats)
		stats.Unmarshal(msg)
		gom.Expect(len(stats.Stats)).Should(gom.Equal(2))
		for _, stat := range stats.Stats {
			gom.Expect(stat.GetValue()).Should(gom.Equal(float64(4)))

		}
	})

	gi.It("Reset Stats to zero", func() {
		stats := make(map[string]*protoStat.ProtoStat)
		key := "key"
		indexKey := "index"
		b := true
		value := float64(200)

		stat := protoStat.ProtoStat{Key: &key, Value: &value, IndexKey: &indexKey, Repeat: &b}