예제 #1
0
파일: flow.go 프로젝트: nathj07/talks
func main() {
	db := common.GetDBConnection()

	providerChan = make(chan *Provider) // unbuffered
	// fetch data
	go fetchData(db)
	// blocking calls
	useData()
	//useDataWorkerPool() // using a worker pool to interleave the tasks
}
예제 #2
0
파일: stopping.go 프로젝트: nathj07/talks
func main() {
	db := common.GetDBConnection()
	providerChan = make(chan *Provider) // unbuffered data chan
	done = make(chan struct{})          // unbuffered control chan
	// fetch data
	go fetchData(db)
	go useData()
	// blocking call
	stop()
}
예제 #3
0
파일: flow.go 프로젝트: nathj07/talks
func main() {
	db := common.GetDBConnection()

	// bounded loop to simulate repeated fetches
	for i := 0; i <= 1; i++ {
		fmt.Println("Iteration ", i)
		providerChan = make(chan *Provider, 10) // buffered chan as we know the amount of data
		go fetchData(db)
		//blocking calls
		useData() // task order is more deterministic
		//useDataWorkerPool() // tasks are more interleaved
	}
}
예제 #4
0
파일: sigint.go 프로젝트: nathj07/talks
func main() {
	db := common.GetDBConnection()
	// NOTIFY OMIT
	providerChan = make(chan *Provider) // unbuffered data chan
	quit = make(chan struct{})          // unbuffered control chans
	done = make(chan struct{})
	go fetchData(db)
	go useData()
	sig := make(chan os.Signal)
	signal.Notify(sig, syscall.SIGINT)
	<-sig
	stop()
	// NOTIFY OMIT
}