fix: Adds missing backend status command implementations.
This commit is contained in:
parent
605ad31dd6
commit
93f2f9cbee
4 changed files with 45 additions and 0 deletions
|
@ -72,6 +72,42 @@ func (helper *BackendApplicationHelper) Start() error {
|
|||
continue
|
||||
}
|
||||
|
||||
helper.socket.Write(responseMarshalled)
|
||||
case "backendStatusRequest":
|
||||
_, ok := commandRaw.(*commonbackend.BackendStatusRequest)
|
||||
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to typecast")
|
||||
}
|
||||
|
||||
ok, err := helper.Backend.GetBackendStatus()
|
||||
|
||||
var (
|
||||
message string
|
||||
statusCode int
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
message = err.Error()
|
||||
statusCode = commonbackend.StatusFailure
|
||||
} else {
|
||||
statusCode = commonbackend.StatusSuccess
|
||||
}
|
||||
|
||||
response := &commonbackend.BackendStatusResponse{
|
||||
Type: "backendStatusResponse",
|
||||
IsRunning: ok,
|
||||
StatusCode: statusCode,
|
||||
Message: message,
|
||||
}
|
||||
|
||||
responseMarshalled, err := commonbackend.Marshal(response.Type, response)
|
||||
|
||||
if err != nil {
|
||||
log.Error("failed to marshal response: %s", err.Error())
|
||||
continue
|
||||
}
|
||||
|
||||
helper.socket.Write(responseMarshalled)
|
||||
case "stop":
|
||||
_, ok := commandRaw.(*commonbackend.Stop)
|
||||
|
|
|
@ -5,6 +5,7 @@ import "git.terah.dev/imterah/hermes/backend/commonbackend"
|
|||
type BackendInterface interface {
|
||||
StartBackend(arguments []byte) (bool, error)
|
||||
StopBackend() (bool, error)
|
||||
GetBackendStatus() (bool, error)
|
||||
StartProxy(command *commonbackend.AddProxy) (bool, error)
|
||||
StopProxy(command *commonbackend.RemoveProxy) (bool, error)
|
||||
GetAllClientConnections() []*commonbackend.ProxyClientConnection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue