mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
improve error handling in case AMQP session is not available
This commit is contained in:
parent
9af822b801
commit
71b103a7c1
2 changed files with 31 additions and 13 deletions
|
@ -168,11 +168,7 @@ func createExternalIC(payload ICUpdate, ICUUID string, body []byte) error {
|
||||||
log.Println("AMQP: Created IC with UUID ", newIC.UUID)
|
log.Println("AMQP: Created IC with UUID ", newIC.UUID)
|
||||||
|
|
||||||
// send ping to get full status update of this IC
|
// send ping to get full status update of this IC
|
||||||
if session != nil {
|
err = SendPing(ICUUID)
|
||||||
err = SendPing(ICUUID)
|
|
||||||
} else {
|
|
||||||
err = fmt.Errorf("cannot sent ping to %v because AMQP session is nil", ICUUID)
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,8 +253,17 @@ func SendPing(uuid string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = session.Send(payload, uuid)
|
if session != nil {
|
||||||
return err
|
if session.IsReady {
|
||||||
|
err = session.Send(payload, uuid)
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("could not send ping, AMQP session not ready")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("could not send ping, AMQP session is nil")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendActionAMQP(action Action, destinationUUID string) error {
|
func sendActionAMQP(action Action, destinationUUID string) error {
|
||||||
|
@ -268,6 +273,15 @@ func sendActionAMQP(action Action, destinationUUID string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = session.Send(payload, destinationUUID)
|
if session != nil {
|
||||||
return err
|
if session.IsReady {
|
||||||
|
err = session.Send(payload, destinationUUID)
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("could not send action, AMQP session is not ready")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("could not send action, AMQP session is nil")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,11 +485,15 @@ func duplicateIC(ic database.InfrastructureComponent, userName string) (string,
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if session.IsReady {
|
if session != nil {
|
||||||
err = session.Send(payload, ic.Manager)
|
if session.IsReady {
|
||||||
return newUUID, err
|
err = session.Send(payload, ic.Manager)
|
||||||
|
return newUUID, err
|
||||||
|
} else {
|
||||||
|
return "", fmt.Errorf("could not send IC create action, AMQP session is not ready")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return "", fmt.Errorf("could not send IC create action, AMQP session is not ready")
|
return "", fmt.Errorf("could not send IC create action, AMQP session is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue