1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Including hostdiscovery conditionaly under a build tag

In order to vendor-in libnetwork to docker, we need to remove the swarm
dependency even though it is used as library. using this PR, a new build
flag libnetwork_discovery is introduced in order to avoid pulling in the
unused hostdiscovery functionality into docker.
We are working with the Swarm project to see if we can modularize the
discovery package to become independent so that we can include them as a
vendor-in package in docker.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
Madhu Venugopal 2015-06-04 04:51:16 -07:00
parent 9d1cc7d56a
commit 5fff515028
5 changed files with 56 additions and 17 deletions

View file

@ -22,7 +22,7 @@ build: ${build_image}.created
${docker} make build-local
build-local:
$(shell which godep) go build -tags experimental ./...
$(shell which godep) go build -tags experimental,libnetwork_discovery ./...
check: ${build_image}.created
${docker} make check-local

View file

@ -1,3 +1,5 @@
// +build libnetwork_discovery
package hostdiscovery
import (
@ -24,22 +26,6 @@ import (
const defaultHeartbeat = 10
// JoinCallback provides a callback event for new node joining the cluster
type JoinCallback func(entries []net.IP)
// LeaveCallback provides a callback event for node leaving the cluster
type LeaveCallback func(entries []net.IP)
// HostDiscovery primary interface
type HostDiscovery interface {
// StartDiscovery initiates the discovery process and provides appropriate callbacks
StartDiscovery(*config.ClusterCfg, JoinCallback, LeaveCallback) error
// StopDiscovery stops the discovery perocess
StopDiscovery() error
// Fetch returns a list of host IPs that are currently discovered
Fetch() ([]net.IP, error)
}
type hostDiscovery struct {
discovery discovery.Discovery
nodes mapset.Set

View file

@ -0,0 +1,23 @@
package hostdiscovery
import (
"net"
"github.com/docker/libnetwork/config"
)
// JoinCallback provides a callback event for new node joining the cluster
type JoinCallback func(entries []net.IP)
// LeaveCallback provides a callback event for node leaving the cluster
type LeaveCallback func(entries []net.IP)
// HostDiscovery primary interface
type HostDiscovery interface {
// StartDiscovery initiates the discovery process and provides appropriate callbacks
StartDiscovery(*config.ClusterCfg, JoinCallback, LeaveCallback) error
// StopDiscovery stops the discovery perocess
StopDiscovery() error
// Fetch returns a list of host IPs that are currently discovered
Fetch() ([]net.IP, error)
}

View file

@ -0,0 +1,28 @@
// +build !libnetwork_discovery
package hostdiscovery
import (
"net"
"github.com/docker/libnetwork/config"
)
type hostDiscovery struct{}
// NewHostDiscovery function creates a host discovery object
func NewHostDiscovery() HostDiscovery {
return &hostDiscovery{}
}
func (h *hostDiscovery) StartDiscovery(cfg *config.ClusterCfg, joinCallback JoinCallback, leaveCallback LeaveCallback) error {
return nil
}
func (h *hostDiscovery) StopDiscovery() error {
return nil
}
func (h *hostDiscovery) Fetch() ([]net.IP, error) {
return []net.IP{}, nil
}

View file

@ -1,3 +1,5 @@
// +build libnetwork_discovery
package hostdiscovery
import (