go-zero/example/mapreduce/finishvoid/finishvoid.go

36 lines
580 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package main
import (
"fmt"
"time"
2020-08-08 16:40:10 +08:00
"github.com/tal-tech/go-zero/core/mr"
"github.com/tal-tech/go-zero/core/timex"
2020-07-26 17:09:05 +08:00
)
func main() {
start := timex.Now()
2020-07-29 22:34:37 +08:00
mr.FinishVoid(func() {
2020-07-26 17:09:05 +08:00
time.Sleep(time.Second)
}, func() {
time.Sleep(time.Second * 5)
}, func() {
time.Sleep(time.Second * 10)
}, func() {
time.Sleep(time.Second * 6)
}, func() {
2020-07-29 22:34:37 +08:00
if err := mr.Finish(func() error {
2020-07-26 17:09:05 +08:00
time.Sleep(time.Second)
return nil
}, func() error {
time.Sleep(time.Second * 10)
return nil
}); err != nil {
fmt.Println(err)
}
})
fmt.Println(timex.Since(start))
}