overflow_probes/service/DiscoveryService.go

56 lines
2.2 KiB
Go
Raw Normal View History

2017-12-04 11:59:51 +00:00
package service
2017-12-05 08:21:47 +00:00
import (
2017-12-08 12:01:38 +00:00
"reflect"
cda "git.loafle.net/commons_go/di/annotation"
cdr "git.loafle.net/commons_go/di/registry"
2017-12-05 08:21:47 +00:00
discoveryM "git.loafle.net/overflow/overflow_commons_go/modules/discovery/model"
2017-12-08 08:31:45 +00:00
oocmp "git.loafle.net/overflow/overflow_commons_go/modules/probe"
oocmpsp "git.loafle.net/overflow/overflow_commons_go/modules/probe/service/probe"
2017-12-05 08:21:47 +00:00
)
2017-12-08 12:01:38 +00:00
func init() {
2018-03-15 13:52:23 +00:00
cdr.RegisterType(reflect.TypeOf((*DiscoveryService)(nil)))
2017-12-08 12:01:38 +00:00
}
2017-12-04 11:59:51 +00:00
type DiscoveryService struct {
2018-03-15 13:52:23 +00:00
cda.TypeAnnotation `annotation:"@overFlow:Service()"`
2017-12-08 08:31:45 +00:00
ContainerService *ContainerService `annotation:"@Inject()"`
CentralService *CentralService `annotation:"@Inject()"`
2017-12-04 11:59:51 +00:00
}
func (ds *DiscoveryService) DiscoverZone(dz *discoveryM.DiscoveryZone) error {
2017-12-08 08:31:45 +00:00
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverZone", dz)
2017-12-04 11:59:51 +00:00
}
2017-12-05 08:21:47 +00:00
func (ds *DiscoveryService) DiscoverHost(zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) error {
2017-12-08 08:31:45 +00:00
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverHost", zone, dh)
2017-12-04 11:59:51 +00:00
}
2017-12-05 08:21:47 +00:00
func (ds *DiscoveryService) DiscoverPort(host *discoveryM.Host, dp *discoveryM.DiscoveryPort) error {
2017-12-08 08:31:45 +00:00
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverPort", host, dp)
2017-12-04 11:59:51 +00:00
}
2017-12-05 10:02:58 +00:00
func (ds *DiscoveryService) DiscoverService(port *discoveryM.Port, dService *discoveryM.DiscoveryService) error {
2017-12-08 08:31:45 +00:00
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverZone", port, dService)
2017-12-04 11:59:51 +00:00
}
2017-12-05 08:21:47 +00:00
// use by discovery
2017-12-04 11:59:51 +00:00
func (ds *DiscoveryService) DiscoveredZone(zone *discoveryM.Zone) error {
2017-12-08 08:31:45 +00:00
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.DiscoveredZone", zone)
2017-12-04 11:59:51 +00:00
}
func (ds *DiscoveryService) DiscoveredHost(host *discoveryM.Host) error {
2017-12-08 08:31:45 +00:00
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.DiscoveredHost", host)
2017-12-04 11:59:51 +00:00
}
func (ds *DiscoveryService) DiscoveredPort(port *discoveryM.Port) error {
2017-12-08 08:31:45 +00:00
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.DiscoveredPort", port)
2017-12-04 11:59:51 +00:00
}
func (ds *DiscoveryService) DiscoveredService(service *discoveryM.Service) error {
2017-12-08 08:31:45 +00:00
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.DiscoveredService", service)
2017-12-04 11:59:51 +00:00
}