9 // Use this to call external services. It will handle timeout and request cancellation gracefully.
10 func CallExternalService(tag string, timeout time.Duration, routine func() *Error) *Error {
11 routineDone := make(chan *Error)
14 routineDone <- routine()
17 ctx, cancel := context.WithTimeout(context.Background(), timeout)
21 case err := <-routineDone:
24 return &Error{ExternalServiceTimeout, "external service timeout", fmt.Errorf("'%v' routine timeouted", tag)}
28 var ErrorChan chan error
30 func ErrorMonitoring() {
33 log.Errorf("error: %v", err)
38 ErrorChan = make(chan error)