overflow_probes/service/DiscoveryService.go

56 lines
2.4 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
}
2018-03-16 06:35:37 +00:00
func (ds *DiscoveryService) DiscoverZone(requesterID string, dz *discoveryM.DiscoveryZone) error {
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverZone", requesterID, dz)
2017-12-04 11:59:51 +00:00
}
2018-03-16 06:35:37 +00:00
func (ds *DiscoveryService) DiscoverHost(requesterID string, zone *discoveryM.Zone, dh *discoveryM.DiscoveryHost) error {
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverHost", requesterID, zone, dh)
2017-12-04 11:59:51 +00:00
}
2018-03-16 06:35:37 +00:00
func (ds *DiscoveryService) DiscoverPort(requesterID string, host *discoveryM.Host, dp *discoveryM.DiscoveryPort) error {
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverPort", requesterID, host, dp)
2017-12-04 11:59:51 +00:00
}
2018-03-16 06:35:37 +00:00
func (ds *DiscoveryService) DiscoverService(requesterID string, port *discoveryM.Port, dService *discoveryM.DiscoveryService) error {
return ds.ContainerService.Send(oocmpsp.ProbeContainerNameDiscovery, "DiscoveryService.DiscoverZone", requesterID, port, dService)
2017-12-04 11:59:51 +00:00
}
2017-12-05 08:21:47 +00:00
// use by discovery
2018-03-16 06:35:37 +00:00
func (ds *DiscoveryService) DiscoveredZone(requesterID string, zone *discoveryM.Zone) error {
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.discoveredZone", requesterID, zone)
2017-12-04 11:59:51 +00:00
}
2018-03-16 06:35:37 +00:00
func (ds *DiscoveryService) DiscoveredHost(requesterID string, host *discoveryM.Host) error {
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.discoveredHost", requesterID, host)
2017-12-04 11:59:51 +00:00
}
2018-03-16 06:35:37 +00:00
func (ds *DiscoveryService) DiscoveredPort(requesterID string, port *discoveryM.Port) error {
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.discoveredPort", requesterID, port)
2017-12-04 11:59:51 +00:00
}
2018-03-16 06:35:37 +00:00
func (ds *DiscoveryService) DiscoveredService(requesterID string, service *discoveryM.Service) error {
return ds.CentralService.Send(oocmp.HTTPEntry_Probe, "DiscoveryService.discoveredService", requesterID, service)
2017-12-04 11:59:51 +00:00
}