Skip to content

Commit

Permalink
Merge pull request kubernetes#465 from smarterclayton/simplify_config…
Browse files Browse the repository at this point in the history
…_for_reuse

Extract proxy/config common functions for reuse
  • Loading branch information
smarterclayton committed Jul 16, 2014
2 parents c78206d + 021cf64 commit 17053f5
Show file tree
Hide file tree
Showing 8 changed files with 582 additions and 325 deletions.
16 changes: 8 additions & 8 deletions cmd/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ func main() {

glog.Infof("Using configuration file %s and etcd_servers %s", *configFile, *etcdServers)

proxyConfig := config.NewServiceConfig()
serviceConfig := config.NewServiceConfig()
endpointsConfig := config.NewEndpointsConfig()

// Create a configuration source that handles configuration from etcd.
etcdClient := etcd.NewClient([]string{*etcdServers})
config.NewConfigSourceEtcd(etcdClient,
proxyConfig.GetServiceConfigurationChannel("etcd"),
proxyConfig.GetEndpointsConfigurationChannel("etcd"))
serviceConfig.Channel("etcd"),
endpointsConfig.Channel("etcd"))

// And create a configuration source that reads from a local file
config.NewConfigSourceFile(*configFile,
proxyConfig.GetServiceConfigurationChannel("file"),
proxyConfig.GetEndpointsConfigurationChannel("file"))
serviceConfig.Channel("file"),
endpointsConfig.Channel("file"))

loadBalancer := proxy.NewLoadBalancerRR()
proxier := proxy.NewProxier(loadBalancer)
// Wire proxier to handle changes to services
proxyConfig.RegisterServiceHandler(proxier)
serviceConfig.RegisterHandler(proxier)
// And wire loadBalancer to handle changes to endpoints to services
proxyConfig.RegisterEndpointsHandler(loadBalancer)
endpointsConfig.RegisterHandler(loadBalancer)

// Just loop forever for now...
select {}

}
Loading

0 comments on commit 17053f5

Please sign in to comment.