コード例 #1
0
ファイル: main.go プロジェクト: jmptrader/goinfo
func main() {
	countDS := &CountsDataSource{}

	goinfo.AddSource(countDS)
	err := goinfo.Start("example")
	if err != nil {
		panic("Oh no! could not mount our monitoring file system: " + err.Error())
	}
	defer goinfo.StopAll()

	//Start app business logic
	for {
		select {
		case <-time.After(500 * time.Millisecond):
			ts := uint64(time.Now().Unix())
			if ts%3 == 0 {
				countDS.arbitraryCountA += 1
				countDS.timestampA = ts
			} else {
				countDS.arbitraryCountB += 1
				countDS.timestampB = ts
			}
		}
	}
}
コード例 #2
0
ファイル: main.go プロジェクト: jmptrader/goinfo
func main() {
	err := goinfo.Start("/opt/go/example")
	if err != nil {
		panic("Oh no! could not mount our monitoring file system: " + err.Error())
	}
	defer goinfo.StopAll()

	//Start app business logic
	select {}
}