probe/service/DiscoveryService.go

89 lines
3.0 KiB
Go
Raw Normal View History

2018-04-13 11:59:46 +00:00
package service
import (
"reflect"
cda "git.loafle.net/commons/di-go/annotation"
cdr "git.loafle.net/commons/di-go/registry"
2018-04-26 08:39:32 +00:00
occp "git.loafle.net/overflow/commons-go/config/probe"
ocmd "git.loafle.net/overflow/commons-go/model/discovery"
2018-04-26 08:43:40 +00:00
ocsp "git.loafle.net/overflow/commons-go/service/probe"
2018-04-18 14:56:13 +00:00
// For annotation
2018-04-13 11:59:46 +00:00
_ "git.loafle.net/overflow/commons-go/core/annotation"
2018-04-26 09:01:49 +00:00
"git.loafle.net/overflow/commons-go/core/util"
2018-04-13 11:59:46 +00:00
)
var DiscoveryServiceType = reflect.TypeOf((*DiscoveryService)(nil))
func init() {
cdr.RegisterType(DiscoveryServiceType)
}
type DiscoveryService struct {
2018-04-26 08:43:40 +00:00
ocsp.DiscoveryService
2018-04-13 11:59:46 +00:00
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-27 16:57:06 +00:00
func (s *DiscoveryService) DiscoverZone(requesterID string, dz *ocmd.DiscoverZone) error {
2018-04-26 08:39:32 +00:00
return s.ContainerService.Send(occp.ContainerDiscovery, "DiscoveryService.DiscoverZone", requesterID, dz)
2018-04-18 14:56:13 +00:00
}
2018-04-13 11:59:46 +00:00
2018-04-27 16:57:06 +00:00
func (s *DiscoveryService) DiscoverHost(requesterID string, zone *ocmd.Zone, dh *ocmd.DiscoverHost) error {
2018-04-26 08:39:32 +00:00
return s.ContainerService.Send(occp.ContainerDiscovery, "DiscoveryService.DiscoverHost", requesterID, zone, dh)
2018-04-18 14:56:13 +00:00
}
2018-04-27 16:57:06 +00:00
func (s *DiscoveryService) DiscoverPort(requesterID string, host *ocmd.Host, dp *ocmd.DiscoverPort) error {
2018-04-26 08:39:32 +00:00
return s.ContainerService.Send(occp.ContainerDiscovery, "DiscoveryService.DiscoverPort", requesterID, host, dp)
2018-04-18 14:56:13 +00:00
}
2018-04-27 16:57:06 +00:00
func (s *DiscoveryService) DiscoverService(requesterID string, port *ocmd.Port, dService *ocmd.DiscoverService) error {
2018-04-26 08:39:32 +00:00
return s.ContainerService.Send(occp.ContainerDiscovery, "DiscoveryService.DiscoverService", requesterID, port, dService)
2018-04-18 14:56:13 +00:00
}
// use by discovery
2018-04-26 09:01:49 +00:00
func (s *DiscoveryService) DiscoveryStart(requesterID string, t *util.Timestamp) error {
2018-04-19 15:03:58 +00:00
return s.ProbeClientService.Send("DiscoveryService.discoveryStart", requesterID, t)
}
2018-04-26 09:01:49 +00:00
func (s *DiscoveryService) DiscoveryStop(requesterID string, t *util.Timestamp) error {
2018-04-19 15:03:58 +00:00
return s.ProbeClientService.Send("DiscoveryService.discoveryStop", requesterID, t)
}
2018-04-26 08:39:32 +00:00
func (s *DiscoveryService) DiscoveredZone(requesterID string, zone *ocmd.Zone) error {
2018-04-18 14:56:13 +00:00
return s.ProbeClientService.Send("DiscoveryService.discoveredZone", requesterID, zone)
}
2018-04-26 08:39:32 +00:00
func (s *DiscoveryService) DiscoveredHost(requesterID string, host *ocmd.Host) error {
2018-04-18 14:56:13 +00:00
return s.ProbeClientService.Send("DiscoveryService.discoveredHost", requesterID, host)
}
2018-04-26 08:39:32 +00:00
func (s *DiscoveryService) DiscoveredPort(requesterID string, port *ocmd.Port) error {
2018-04-18 14:56:13 +00:00
return s.ProbeClientService.Send("DiscoveryService.discoveredPort", requesterID, port)
}
2018-04-26 08:39:32 +00:00
func (s *DiscoveryService) DiscoveredService(requesterID string, service *ocmd.Service) error {
2018-04-18 14:56:13 +00:00
return s.ProbeClientService.Send("DiscoveryService.discoveredService", requesterID, service)
2018-04-13 11:59:46 +00:00
}