feature: Refactors backend runtime's communication mechanism to be more stable.
This commit is contained in:
parent
93f2f9cbee
commit
1e1a330a4b
10 changed files with 254 additions and 157 deletions
|
@ -110,25 +110,25 @@ func RemoveProxy(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
backend.RuntimeCommands <- &commonbackend.RemoveProxy{
|
||||
backendResponse, err := backend.ProcessCommand(&commonbackend.RemoveProxy{
|
||||
Type: "removeProxy",
|
||||
SourceIP: proxy.SourceIP,
|
||||
SourcePort: proxy.SourcePort,
|
||||
DestPort: proxy.DestinationPort,
|
||||
Protocol: proxy.Protocol,
|
||||
}
|
||||
})
|
||||
|
||||
backendResponse := <-backend.RuntimeCommands
|
||||
|
||||
switch responseMessage := backendResponse.(type) {
|
||||
case error:
|
||||
log.Warnf("Failed to get response for backend #%d: %s", proxy.BackendID, responseMessage.Error())
|
||||
if err != nil {
|
||||
log.Warnf("Failed to get response for backend #%d: %s", proxy.BackendID, err.Error())
|
||||
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": "Failed to get response from backend. Proxy was still successfully deleted",
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
switch responseMessage := backendResponse.(type) {
|
||||
case *commonbackend.ProxyStatusResponse:
|
||||
if responseMessage.IsActive {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue