probe/service/DiscoveryService.go
crusader e6889911bb ing
2018-04-26 18:01:49 +09:00

89 lines
3.0 KiB
Go

package service
import (
"reflect"
cda "git.loafle.net/commons/di-go/annotation"
cdr "git.loafle.net/commons/di-go/registry"
occp "git.loafle.net/overflow/commons-go/config/probe"
ocmd "git.loafle.net/overflow/commons-go/model/discovery"
ocsp "git.loafle.net/overflow/commons-go/service/probe"
// For annotation
_ "git.loafle.net/overflow/commons-go/core/annotation"
"git.loafle.net/overflow/commons-go/core/util"
)
var DiscoveryServiceType = reflect.TypeOf((*DiscoveryService)(nil))
func init() {
cdr.RegisterType(DiscoveryServiceType)
}
type DiscoveryService struct {
ocsp.DiscoveryService
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 *ocmd.DiscoveryZone) error {
return s.ContainerService.Send(occp.ContainerDiscovery, "DiscoveryService.DiscoverZone", requesterID, dz)
}
func (s *DiscoveryService) DiscoverHost(requesterID string, zone *ocmd.Zone, dh *ocmd.DiscoveryHost) error {
return s.ContainerService.Send(occp.ContainerDiscovery, "DiscoveryService.DiscoverHost", requesterID, zone, dh)
}
func (s *DiscoveryService) DiscoverPort(requesterID string, host *ocmd.Host, dp *ocmd.DiscoveryPort) error {
return s.ContainerService.Send(occp.ContainerDiscovery, "DiscoveryService.DiscoverPort", requesterID, host, dp)
}
func (s *DiscoveryService) DiscoverService(requesterID string, port *ocmd.Port, dService *ocmd.DiscoveryService) error {
return s.ContainerService.Send(occp.ContainerDiscovery, "DiscoveryService.DiscoverService", requesterID, port, dService)
}
// use by discovery
func (s *DiscoveryService) DiscoveryStart(requesterID string, t *util.Timestamp) error {
return s.ProbeClientService.Send("DiscoveryService.discoveryStart", requesterID, t)
}
func (s *DiscoveryService) DiscoveryStop(requesterID string, t *util.Timestamp) error {
return s.ProbeClientService.Send("DiscoveryService.discoveryStop", requesterID, t)
}
func (s *DiscoveryService) DiscoveredZone(requesterID string, zone *ocmd.Zone) error {
return s.ProbeClientService.Send("DiscoveryService.discoveredZone", requesterID, zone)
}
func (s *DiscoveryService) DiscoveredHost(requesterID string, host *ocmd.Host) error {
return s.ProbeClientService.Send("DiscoveryService.discoveredHost", requesterID, host)
}
func (s *DiscoveryService) DiscoveredPort(requesterID string, port *ocmd.Port) error {
return s.ProbeClientService.Send("DiscoveryService.discoveredPort", requesterID, port)
}
func (s *DiscoveryService) DiscoveredService(requesterID string, service *ocmd.Service) error {
return s.ProbeClientService.Send("DiscoveryService.discoveredService", requesterID, service)
}