示例#1
0
func (ls *GetUserDataService) GetUserData(cr *myStartup.GetUserDataRequest, lr *myStartup.GetUserDataResponse) (err os.Error) {
	result := make(chan string)
	timeout := make(chan bool)

	//This function produces the actual result
	go func() {
		time.Sleep(1e8) // force the fail
		result <- " was here"
	}()

	go func() {
		time.Sleep(1e9)
		timeout <- true
	}()

	select {
	case retVal := <-result:
		lr.YourOutputValue = cr.YourInputValue + retVal
	case <-timeout:
		lr.Errors = append(lr.Errors, "Service Timeout")
	}

	skylib.Requests.Add(1)
	return nil
}