58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"log"
|
|
"reflect"
|
|
|
|
oa "git.loafle.net/overflow/annotation-go"
|
|
od "git.loafle.net/overflow/di-go"
|
|
omd "git.loafle.net/overflow/model/discovery"
|
|
ounp "git.loafle.net/overflow/util-go/net/ping"
|
|
"git.loafle.net/overflow_scanner/probe/ping"
|
|
)
|
|
|
|
func init() {
|
|
od.RegisterType(PingServiceType)
|
|
}
|
|
|
|
var PingServiceType = reflect.TypeOf((*PingService)(nil))
|
|
|
|
type PingService struct {
|
|
oa.TypeAnnotation `annotation:"@Injectable('name': 'PingService') @Service()"`
|
|
|
|
_InitService oa.MethodAnnotation `annotation:"@PostConstruct()"`
|
|
_DestroyService oa.MethodAnnotation `annotation:"@PreDestroy()"`
|
|
}
|
|
|
|
func (s *PingService) InitService() {
|
|
|
|
}
|
|
|
|
func (s *PingService) DestroyService() {
|
|
|
|
}
|
|
|
|
func (s *PingService) PingHost(host *omd.Host, pingOption *ounp.PingOption) (*ounp.PingResult, error) {
|
|
result, err := ping.PingHost(host, pingOption)
|
|
if nil != err {
|
|
log.Print(err)
|
|
return nil, err
|
|
}
|
|
|
|
return result.(*ounp.PingResult), nil
|
|
}
|
|
|
|
func (s *PingService) PingService(service *omd.Service, pingOption *ounp.PingOption) (*ounp.PingResult, error) {
|
|
result, err := ping.PingService(service, pingOption)
|
|
if nil != err {
|
|
log.Print(err)
|
|
return nil, err
|
|
}
|
|
|
|
return result.(*ounp.PingResult), nil
|
|
}
|
|
|
|
func (s *PingService) PingAll() error {
|
|
return nil
|
|
}
|