예제 #1
0
func (f *Sleeper) Sleep(ri *skynet.RequestInfo, req sleeper.Request,
	resp *sleeper.Response) (err error) {

	log.Println("sleeping for", req.Duration, req.Message)

	if req.UnregisterHalfwayThrough {
		go func() {
			time.Sleep(req.Duration / 2)
			f.service.Unregister()
		}()
	}

	time.Sleep(req.Duration)

	resp.Message = req.Message

	if req.UnregisterWhenDone {
		f.service.Unregister()
	}

	if req.PanicWhenDone {
		panic("panic requested by client")
	}

	if req.ExitWhenDone {
		os.Exit(0)
	}

	return
}
예제 #2
0
func (f *Sleeper) Sleep(ri *skynet.RequestInfo, req sleeper.Request, resp *sleeper.Response) (err error) {
	time.Sleep(req.Duration)

	resp.Message = req.Message

	return
}