container_discovery/internal/discoverer/service.go

27 lines
816 B
Go
Raw Normal View History

2018-04-19 11:36:56 +00:00
package discoverer
import (
"fmt"
2018-04-26 09:00:24 +00:00
ocmd "git.loafle.net/overflow/commons-go/model/discovery"
2018-06-13 10:20:14 +00:00
ocmm "git.loafle.net/overflow/commons-go/model/meta"
2018-04-19 11:36:56 +00:00
"git.loafle.net/overflow/container_discovery/internal/discoverer/ipv4"
"git.loafle.net/overflow/container_discovery/internal/discoverer/ipv6"
)
2018-04-27 16:20:01 +00:00
func scanService(port *ocmd.Port, ds *ocmd.DiscoverService, resultChan chan interface{}, errChan chan error, doneChan chan<- struct{}, stopChan chan struct{}) {
2018-04-19 11:36:56 +00:00
defer func() {
doneChan <- struct{}{}
}()
2018-06-13 10:20:14 +00:00
switch ocmm.ToMetaIPTypeEnum(port.Host.MetaIPType) {
case ocmm.MetaIPTypeEnumV4:
2018-04-19 11:36:56 +00:00
ipv4.ScanService(port, ds, resultChan, errChan, stopChan)
2018-06-13 10:20:14 +00:00
case ocmm.MetaIPTypeEnumV6:
2018-04-19 11:36:56 +00:00
ipv6.ScanService(port, ds, resultChan, errChan, stopChan)
default:
2018-06-13 10:20:14 +00:00
errChan <- fmt.Errorf("Discovery: Not supported MetaIPType")
2018-04-19 11:36:56 +00:00
}
2018-06-13 10:20:14 +00:00
2018-04-19 11:36:56 +00:00
}