示例#1
0
func getAndMatch(uri string, pattern *regexp.Regexp) chan *uriMatchChanPair {
	// TODO: Read in the value of n
	retries := uint32(3)

	getter := expb.NewUrlGetter(uri, retries)
	chanOPair := make(chan *uriMatchChanPair)

	go func() {
		expb.ExponentialBackOff(getter, func(resp interface{}, err error) {
			defer close(chanOPair)

			lines := responseStringer(resp, err)

			matchesChan := extractAndMatch(lines, pattern)
			uriChan := extractAndMatch(lines, uriRegCompile)

			chanOPair <- &uriMatchChanPair{uriChan: uriChan, matchesChan: matchesChan}
		})
	}()

	return chanOPair
}
示例#2
0
文件: main.go 项目: YuhsiangLu/drive
func main() {
	backer := expb.NewUrlGetter("https://golang.org/pkg/net/httpx", 5)
	expb.ExponentialBackOff(backer, consume)
	fmt.Println("expb")
}