package service import ( "reflect" "time" cda "git.loafle.net/commons/di-go/annotation" cdr "git.loafle.net/commons/di-go/registry" ocdm "git.loafle.net/overflow/commons-go/discovery/model" ocpcc "git.loafle.net/overflow/commons-go/probe/constants" // For annotation _ "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()"` ContainerService *ContainerService `annotation:"@Inject()"` ProbeClientService *ProbeClientService `annotation:"@Inject()"` } func (s *DiscoveryService) InitService() error { return nil } func (s *DiscoveryService) StartService() error { return nil } func (s *DiscoveryService) StopService() { } func (s *DiscoveryService) DestroyService() { } func (s *DiscoveryService) DiscoverZone(requesterID string, dz *ocdm.DiscoveryZone) error { return s.ContainerService.Send(ocpcc.ContainerDiscovery, "DiscoveryService.DiscoverZone", requesterID, dz) } 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 { return s.ContainerService.Send(ocpcc.ContainerDiscovery, "DiscoveryService.DiscoverService", requesterID, port, dService) } // use by discovery 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) } 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) }