feat(watchdog): add watchdog service with TCP client implementation
- Implement TCP client for watchdog service communication - Add watchdog configuration in config.json - Update main.go to initialize and connect to watchdog - Add watchdog related functions (connect, command handling) - Update README.md with new watchdog feature - Improve route setup logging in router.go
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package watchdog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func AddInstance(serviceName string) bool {
|
||||
if !IsConnected() {
|
||||
return false
|
||||
}
|
||||
|
||||
message := fmt.Sprintf("[addInstance] <serviceName>%s</serviceName>", serviceName)
|
||||
response, err := sendMsg(message, 3)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return response == "success"
|
||||
}
|
||||
|
||||
func RemoveInstance(serviceName string) bool {
|
||||
if !IsConnected() {
|
||||
return false
|
||||
}
|
||||
|
||||
message := fmt.Sprintf("[removeInstance] <serviceName>%s</serviceName>", serviceName)
|
||||
response, err := sendMsg(message, 3)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return response == "success"
|
||||
}
|
||||
Reference in New Issue
Block a user