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 }
// Call the RPC service on the router to process the GetUserDataRequest. func submitGetUserDataRequest(cr *myStartup.GetUserDataRequest) (*myStartup.GetUserDataResponse, os.Error) { var GetUserDataResponse *myStartup.GetUserDataResponse client, err := skylib.GetRandomClientByProvides("RouteService.RouteGetUserDataRequest") if err != nil { if GetUserDataResponse == nil { GetUserDataResponse = &myStartup.GetUserDataResponse{} } GetUserDataResponse.Errors = append(GetUserDataResponse.Errors, err.String()) return GetUserDataResponse, err } err = client.Call("RouteService.RouteGetUserDataRequest", cr, &GetUserDataResponse) if err != nil { if GetUserDataResponse == nil { GetUserDataResponse = &myStartup.GetUserDataResponse{} } GetUserDataResponse.Errors = append(GetUserDataResponse.Errors, err.String()) } return GetUserDataResponse, nil }