overflow_probes/service/DiscoveryService.go
crusader ca13dea9cd ing
2018-03-26 15:55:38 +09:00

69 lines
2.6 KiB
Go

package service
import (
"context"
"reflect"
cda "git.loafle.net/commons_go/di/annotation"
cdr "git.loafle.net/commons_go/di/registry"
ooccp "git.loafle.net/overflow/overflow_commons_go/config/probe"
oocmci "git.loafle.net/overflow/overflow_commons_go/modules/commons/interfaces"
discoveryM "git.loafle.net/overflow/overflow_commons_go/modules/discovery/model"
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
)
func init() {
cdr.RegisterType(reflect.TypeOf((*DiscoveryService)(nil)))
}
type DiscoveryService struct {
cda.TypeAnnotation `annotation:"@overFlow:Service()"`
oocmci.Service
ContainerService *ContainerService `annotation:"@Inject()"`
CentralService *CentralService `annotation:"@Inject()"`
}
func (ds *DiscoveryService) Start() error {
return nil
}
func (ds *DiscoveryService) Stop(ctx context.Context) error {
return nil
}
func (ds *DiscoveryService) DiscoverZone(requesterID string, dz *discoveryM.DiscoveryZone) error {
return ds.ContainerService.Send(ooccp.ContainerDiscoveryName, "DiscoveryService.DiscoverZone", requesterID, dz)
}
func (ds *DiscoveryService) DiscoverHost(requesterID string, zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) error {
return ds.ContainerService.Send(ooccp.ContainerDiscoveryName, "DiscoveryService.DiscoverHost", requesterID, zone, dh)
}
func (ds *DiscoveryService) DiscoverPort(requesterID string, host *discoveryM.Host, dp *discoveryM.DiscoveryPort) error {
return ds.ContainerService.Send(ooccp.ContainerDiscoveryName, "DiscoveryService.DiscoverPort", requesterID, host, dp)
}
func (ds *DiscoveryService) DiscoverService(requesterID string, port *discoveryM.Port, dService *discoveryM.DiscoveryService) error {
return ds.ContainerService.Send(ooccp.ContainerDiscoveryName, "DiscoveryService.DiscoverZone", requesterID, port, dService)
}
// use by discovery
func (ds *DiscoveryService) DiscoveredZone(requesterID string, zone *discoveryM.Zone) error {
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.discoveredZone", requesterID, zone)
}
func (ds *DiscoveryService) DiscoveredHost(requesterID string, host *discoveryM.Host) error {
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.discoveredHost", requesterID, host)
}
func (ds *DiscoveryService) DiscoveredPort(requesterID string, port *discoveryM.Port) error {
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.discoveredPort", requesterID, port)
}
func (ds *DiscoveryService) DiscoveredService(requesterID string, service *discoveryM.Service) error {
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.discoveredService", requesterID, service)
}