This commit is contained in:
crusader
2018-09-04 16:07:45 +09:00
parent 126472bc2d
commit fdb2635edc
6 changed files with 56 additions and 34 deletions

View File

@@ -20,39 +20,13 @@ var DiscoveryServiceType = reflect.TypeOf((*DiscoveryService)(nil))
type DiscoveryService struct {
oa.TypeAnnotation `annotation:"@Injectable('name': 'DiscoveryService') @Service()"`
Discoverer discovery.Discoverer `annotation:"@Resource('name': 'Discoverer')"`
Discoverer discovery.Discoverer `annotation:"@Inject('name': 'Discoverer')"`
_InitService oa.MethodAnnotation `annotation:"@PostConstruct()"`
_DestroyService oa.MethodAnnotation `annotation:"@PreDestroy()"`
}
func (s *DiscoveryService) InitService() error {
return nil
}
func (s *DiscoveryService) StartService() error {
go func() {
for {
select {
case msg, ok := <-s.Discoverer.Message():
if !ok {
return
}
log.Print(msg)
}
}
}()
return nil
}
func (s *DiscoveryService) StopService() {
s.Discoverer.Shutdown()
}
func (s *DiscoveryService) DestroyService() {
}
func (s *DiscoveryService) DiscoverHost(requesterID string, zone *omd.Zone, dh *omd.DiscoverHost) error {
func (s *DiscoveryService) InitService() {
go func() {
for {
select {
@@ -87,6 +61,13 @@ func (s *DiscoveryService) DiscoverHost(requesterID string, zone *omd.Zone, dh *
}
}
}()
}
func (s *DiscoveryService) DestroyService() {
}
func (s *DiscoveryService) DiscoverHost(requesterID string, zone *omd.Zone, dh *omd.DiscoverHost) error {
s.Discoverer.DiscoverHost(requesterID, zone, dh)
return nil

View File

@@ -17,6 +17,17 @@ var MachineServiceType = reflect.TypeOf((*MachineService)(nil))
type MachineService struct {
oa.TypeAnnotation `annotation:"@Injectable('name': 'MachineService') @Service()"`
_InitService oa.MethodAnnotation `annotation:"@PostConstruct()"`
_DestroyService oa.MethodAnnotation `annotation:"@PreDestroy()"`
}
func (s *MachineService) InitService() {
}
func (s *MachineService) DestroyService() {
}
func (s *MachineService) Interfaces() ([]*omn.Interface, error) {

View File

@@ -15,8 +15,18 @@ 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() error {
return nil
}

View File

@@ -15,8 +15,18 @@ var SNMPServiceType = reflect.TypeOf((*SNMPService)(nil))
type SNMPService struct {
oa.TypeAnnotation `annotation:"@Injectable('name': 'SNMPService') @Service()"`
_InitService oa.MethodAnnotation `annotation:"@PostConstruct()"`
_DestroyService oa.MethodAnnotation `annotation:"@PreDestroy()"`
}
func (s *SNMPService) InitService() {
}
func (s *SNMPService) DestroyService() {
}
func (s *SNMPService) ScanSNMP() error {
return nil
}