2018-08-23 09:21:48 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2018-09-17 16:30:17 +00:00
|
|
|
"log"
|
2018-08-23 09:21:48 +00:00
|
|
|
"reflect"
|
|
|
|
|
|
|
|
oa "git.loafle.net/overflow/annotation-go"
|
|
|
|
od "git.loafle.net/overflow/di-go"
|
2018-09-17 14:18:49 +00:00
|
|
|
omd "git.loafle.net/overflow/model/discovery"
|
2018-09-17 16:25:56 +00:00
|
|
|
ounp "git.loafle.net/overflow/util-go/net/ping"
|
|
|
|
"git.loafle.net/overflow_scanner/probe/ping"
|
2018-08-23 09:21:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
od.RegisterType(PingServiceType)
|
|
|
|
}
|
|
|
|
|
|
|
|
var PingServiceType = reflect.TypeOf((*PingService)(nil))
|
|
|
|
|
|
|
|
type PingService struct {
|
|
|
|
oa.TypeAnnotation `annotation:"@Injectable('name': 'PingService') @Service()"`
|
2018-09-04 07:07:45 +00:00
|
|
|
|
|
|
|
_InitService oa.MethodAnnotation `annotation:"@PostConstruct()"`
|
|
|
|
_DestroyService oa.MethodAnnotation `annotation:"@PreDestroy()"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *PingService) InitService() {
|
|
|
|
|
2018-08-23 09:21:48 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 07:07:45 +00:00
|
|
|
func (s *PingService) DestroyService() {
|
|
|
|
|
|
|
|
}
|
2018-09-17 14:18:49 +00:00
|
|
|
|
2018-09-17 16:25:56 +00:00
|
|
|
func (s *PingService) PingHost(host *omd.Host, pingOption *ounp.PingOption) (*ounp.PingResult, error) {
|
2018-09-17 16:30:17 +00:00
|
|
|
result, err := ping.PingHost(host, pingOption)
|
|
|
|
if nil != err {
|
|
|
|
log.Print(err)
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result.(*ounp.PingResult), nil
|
2018-08-23 09:21:48 +00:00
|
|
|
}
|
|
|
|
|
2018-09-17 16:25:56 +00:00
|
|
|
func (s *PingService) PingService(service *omd.Service, pingOption *ounp.PingOption) (*ounp.PingResult, error) {
|
2018-09-17 16:30:17 +00:00
|
|
|
result, err := ping.PingService(service, pingOption)
|
|
|
|
if nil != err {
|
|
|
|
log.Print(err)
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result.(*ounp.PingResult), nil
|
2018-08-23 09:21:48 +00:00
|
|
|
}
|
|
|
|
|
2018-08-23 10:00:34 +00:00
|
|
|
func (s *PingService) PingAll() error {
|
|
|
|
return nil
|
2018-08-23 09:21:48 +00:00
|
|
|
}
|