overflow_probes/service/DiscoveryService.go

69 lines
2.6 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 (
2018-03-26 06:55:38 +00:00
"context"
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"
2018-03-21 10:22:13 +00:00
ooccp "git.loafle.net/overflow/overflow_commons_go/config/probe"
2018-03-26 06:55:38 +00:00
oocmci "git.loafle.net/overflow/overflow_commons_go/modules/commons/interfaces"
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"
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()"`
2018-03-26 06:55:38 +00:00
oocmci.Service
2018-03-15 13:52:23 +00:00
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-26 06:55:38 +00:00
func (ds *DiscoveryService) Start() error {
return nil
}
func (ds *DiscoveryService) Stop(ctx context.Context) error {
return nil
}
2018-03-16 06:35:37 +00:00
func (ds *DiscoveryService) DiscoverZone(requesterID string, dz *discoveryM.DiscoveryZone) error {
2018-03-21 10:22:13 +00:00
return ds.ContainerService.Send(ooccp.ContainerDiscoveryName, "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 {
2018-03-21 10:22:13 +00:00
return ds.ContainerService.Send(ooccp.ContainerDiscoveryName, "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 {
2018-03-21 10:22:13 +00:00
return ds.ContainerService.Send(ooccp.ContainerDiscoveryName, "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 {
2018-03-21 10:22:13 +00:00
return ds.ContainerService.Send(ooccp.ContainerDiscoveryName, "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
}