Esempio n. 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
}
Esempio n. 2
0
// Call the RPC service on the router to process the GetUserDataRequest.
func submitGetUserDataRequest(cr *myStartup.GetUserDataRequest) (*myStartup.GetUserDataResponse, os.Error) {
	var GetUserDataResponse *myStartup.GetUserDataResponse

	service := "RouteService"
	client, err := skylib.GetRandomClientByService(service)
	if err != nil {
		if GetUserDataResponse == nil {
			GetUserDataResponse = &myStartup.GetUserDataResponse{}
		}
		GetUserDataResponse.Errors = append(GetUserDataResponse.Errors, err.String())
		return GetUserDataResponse, err
	}
	err = client.Call(service+".RouteGetUserDataRequest", cr, &GetUserDataResponse)
	if err != nil {
		if GetUserDataResponse == nil {
			GetUserDataResponse = &myStartup.GetUserDataResponse{}

		}
		GetUserDataResponse.Errors = append(GetUserDataResponse.Errors, err.String())
	}

	return GetUserDataResponse, nil
}