2018-04-13 11:59:46 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
2018-04-19 15:03:58 +00:00
|
|
|
"time"
|
2018-04-13 11:59:46 +00:00
|
|
|
|
|
|
|
cda "git.loafle.net/commons/di-go/annotation"
|
|
|
|
cdr "git.loafle.net/commons/di-go/registry"
|
2018-04-18 14:56:13 +00:00
|
|
|
ocdm "git.loafle.net/overflow/commons-go/discovery/model"
|
|
|
|
ocpcc "git.loafle.net/overflow/commons-go/probe/constants"
|
|
|
|
|
|
|
|
// For annotation
|
2018-04-13 11:59:46 +00:00
|
|
|
_ "git.loafle.net/overflow/commons-go/core/annotation"
|
|
|
|
)
|
|
|
|
|
|
|
|
var DiscoveryServiceType = reflect.TypeOf((*DiscoveryService)(nil))
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cdr.RegisterType(DiscoveryServiceType)
|
|
|
|
}
|
|
|
|
|
|
|
|
type DiscoveryService struct {
|
|
|
|
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
|
2018-04-18 14:56:13 +00:00
|
|
|
|
|
|
|
ContainerService *ContainerService `annotation:"@Inject()"`
|
|
|
|
ProbeClientService *ProbeClientService `annotation:"@Inject()"`
|
2018-04-13 11:59:46 +00:00
|
|
|
}
|
|
|
|
|
2018-04-17 14:11:13 +00:00
|
|
|
func (s *DiscoveryService) InitService() error {
|
2018-04-18 14:56:13 +00:00
|
|
|
|
2018-04-17 14:11:13 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DiscoveryService) StartService() error {
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DiscoveryService) StopService() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DiscoveryService) DestroyService() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-04-18 14:56:13 +00:00
|
|
|
func (s *DiscoveryService) DiscoverZone(requesterID string, dz *ocdm.DiscoveryZone) error {
|
|
|
|
return s.ContainerService.Send(ocpcc.ContainerDiscovery, "DiscoveryService.DiscoverZone", requesterID, dz)
|
|
|
|
}
|
2018-04-13 11:59:46 +00:00
|
|
|
|
2018-04-18 14:56:13 +00:00
|
|
|
func (s *DiscoveryService) DiscoverHost(requesterID string, zone *ocdm.Zone, dh *ocdm.DiscoveryHost) error {
|
|
|
|
return s.ContainerService.Send(ocpcc.ContainerDiscovery, "DiscoveryService.DiscoverHost", requesterID, zone, dh)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DiscoveryService) DiscoverPort(requesterID string, host *ocdm.Host, dp *ocdm.DiscoveryPort) error {
|
|
|
|
return s.ContainerService.Send(ocpcc.ContainerDiscovery, "DiscoveryService.DiscoverPort", requesterID, host, dp)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DiscoveryService) DiscoverService(requesterID string, port *ocdm.Port, dService *ocdm.DiscoveryService) error {
|
2018-04-19 15:03:58 +00:00
|
|
|
return s.ContainerService.Send(ocpcc.ContainerDiscovery, "DiscoveryService.DiscoverService", requesterID, port, dService)
|
2018-04-18 14:56:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// use by discovery
|
2018-04-19 15:03:58 +00:00
|
|
|
func (s *DiscoveryService) DiscoveryStart(requesterID string, t *time.Time) error {
|
|
|
|
return s.ProbeClientService.Send("DiscoveryService.discoveryStart", requesterID, t)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DiscoveryService) DiscoveryStop(requesterID string, t *time.Time) error {
|
|
|
|
return s.ProbeClientService.Send("DiscoveryService.discoveryStop", requesterID, t)
|
|
|
|
}
|
|
|
|
|
2018-04-18 14:56:13 +00:00
|
|
|
func (s *DiscoveryService) DiscoveredZone(requesterID string, zone *ocdm.Zone) error {
|
|
|
|
return s.ProbeClientService.Send("DiscoveryService.discoveredZone", requesterID, zone)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DiscoveryService) DiscoveredHost(requesterID string, host *ocdm.Host) error {
|
|
|
|
return s.ProbeClientService.Send("DiscoveryService.discoveredHost", requesterID, host)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DiscoveryService) DiscoveredPort(requesterID string, port *ocdm.Port) error {
|
|
|
|
return s.ProbeClientService.Send("DiscoveryService.discoveredPort", requesterID, port)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DiscoveryService) DiscoveredService(requesterID string, service *ocdm.Service) error {
|
|
|
|
return s.ProbeClientService.Send("DiscoveryService.discoveredService", requesterID, service)
|
2018-04-13 11:59:46 +00:00
|
|
|
}
|