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


Golang Variable.String方法代碼示例

本文整理匯總了Golang中github.com/dparrish/openinstrument/variable.Variable.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang Variable.String方法的具體用法?Golang Variable.String怎麽用?Golang Variable.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/dparrish/openinstrument/variable.Variable的用法示例。


在下文中一共展示了Variable.String方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Reader

// Reader builds a channel that will return streams for a supplied Variable.
// If min/maxTimestamp are not nil, streams will only be returned if SOME values inside the stream match.
// The supplied variable may be a search or a single.
// The streams returned may be out of order with respect to variable names or timestamps.
func (ds *Datastore) Reader(ctx context.Context, v *variable.Variable) <-chan *oproto.ValueStream {
	varName := v.String()
	openinstrument.Logf(ctx, "Creating Reader for %s between %d and %d\n", varName, v.MinTimestamp, v.MaxTimestamp)
	out := make(chan *oproto.ValueStream, 100)
	go func() {
		defer close(out)
		ds.blocksLock.RLock()
		defer ds.blocksLock.RUnlock()
		for _, block := range ds.blocks {
			for stream := range block.Reader(ctx, v) {
				out <- stream
			}
		}
	}()
	return out
}
開發者ID:dparrish,項目名稱:openinstrument,代碼行數:20,代碼來源:datastore.go

示例2: Reader

func (s *FakeReadableStore) Reader(ctx context.Context, v *variable.Variable) <-chan *oproto.ValueStream {
	c := make(chan *oproto.ValueStream, 100)
	go func() {
		defer close(c)
		switch v.String() {
		case "/test/offset":
			c <- &oproto.ValueStream{
				Variable: v.AsProto(),
				Value: []*oproto.Value{
					{Timestamp: uint64(0), DoubleValue: float64(20)},
					{Timestamp: uint64(61), DoubleValue: float64(40)},
					{Timestamp: uint64(122), DoubleValue: float64(60)},
					{Timestamp: uint64(185), DoubleValue: float64(80)},
					{Timestamp: uint64(241), DoubleValue: float64(100)},
					{Timestamp: uint64(299), DoubleValue: float64(122)},
					{Timestamp: uint64(330), DoubleValue: float64(132)},
					{Timestamp: uint64(359), DoubleValue: float64(140)},
					{Timestamp: uint64(421), DoubleValue: float64(160)},
					{Timestamp: uint64(488), DoubleValue: float64(180)},
					{Timestamp: uint64(540), DoubleValue: float64(200)},
					{Timestamp: uint64(975), DoubleValue: float64(275)},
				},
			}
		default:
			c <- &oproto.ValueStream{
				Variable: v.AsProto(),
				Value: []*oproto.Value{
					{Timestamp: uint64(60 * 0), DoubleValue: float64(20 * 1)},
					{Timestamp: uint64(60 * 1), DoubleValue: float64(20 * 2)},
					{Timestamp: uint64(60 * 2), DoubleValue: float64(20 * 3)},
					{Timestamp: uint64(60 * 3), DoubleValue: float64(20 * 4)},
					{Timestamp: uint64(60 * 4), DoubleValue: float64(20 * 5)},
					{Timestamp: uint64(60 * 5), DoubleValue: float64(20 * 6)},
					{Timestamp: uint64(60 * 6), DoubleValue: float64(20 * 7)},
					{Timestamp: uint64(60 * 7), DoubleValue: float64(20 * 8)},
					{Timestamp: uint64(60 * 8), DoubleValue: float64(20 * 9)},
					{Timestamp: uint64(60 * 9), DoubleValue: float64(20 * 10)},
					{Timestamp: uint64(60 * 10), DoubleValue: float64(20 * 11)},
				},
			}
		}
	}()
	return c
}
開發者ID:dparrish,項目名稱:openinstrument,代碼行數:44,代碼來源:mutations_test.go


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