From 142c5a963dfee5990743675ba3f5101c057e5cd7 Mon Sep 17 00:00:00 2001 From: Wojciech Tyczynski Date: Fri, 17 Mar 2017 15:29:44 +0100 Subject: [PATCH] Cleanup proxy/config --- pkg/proxy/config/config.go | 29 ++++------------------------- pkg/proxy/config/config_test.go | 18 ------------------ 2 files changed, 4 insertions(+), 43 deletions(-) diff --git a/pkg/proxy/config/config.go b/pkg/proxy/config/config.go index 2dddefa0e25..bb558316f73 100644 --- a/pkg/proxy/config/config.go +++ b/pkg/proxy/config/config.go @@ -31,31 +31,6 @@ import ( "k8s.io/kubernetes/pkg/util/config" ) -// Operation is a type of operation of services or endpoints. -type Operation int - -// These are the available operation types. -const ( - ADD Operation = iota - UPDATE - REMOVE - SYNCED -) - -// ServiceUpdate describes an operation of services, sent on the channel. -// You can add, update or remove single service by setting Op == ADD|UPDATE|REMOVE. -type ServiceUpdate struct { - Service *api.Service - Op Operation -} - -// EndpointsUpdate describes an operation of endpoints, sent on the channel. -// You can add, update or remove single endpoints by setting Op == ADD|UPDATE|REMOVE. -type EndpointsUpdate struct { - Endpoints *api.Endpoints - Op Operation -} - // ServiceConfigHandler is an abstract interface of objects which receive update notifications for the set of services. type ServiceConfigHandler interface { // OnServiceUpdate gets called when a configuration has been changed by one of the sources. @@ -118,6 +93,8 @@ func (c *EndpointsConfig) RegisterHandler(handler EndpointsConfigHandler) { c.handlers = append(c.handlers, handler) } +// Run starts the underlying informer and goroutine responsible for calling +// registered handlers. func (c *EndpointsConfig) Run(stopCh <-chan struct{}) { // The updates channel is used to send interrupts to the Endpoints handler. // It's buffered because we never want to block for as long as there is a @@ -217,6 +194,8 @@ func (c *ServiceConfig) RegisterHandler(handler ServiceConfigHandler) { c.handlers = append(c.handlers, handler) } +// Run starts the underlying informer and goroutine responsible for calling +// registered handlers. func (c *ServiceConfig) Run(stopCh <-chan struct{}) { // The updates channel is used to send interrupts to the Services handler. // It's buffered because we never want to block for as long as there is a diff --git a/pkg/proxy/config/config_test.go b/pkg/proxy/config/config_test.go index 9f852a67814..8608e88f732 100644 --- a/pkg/proxy/config/config_test.go +++ b/pkg/proxy/config/config_test.go @@ -28,16 +28,6 @@ import ( "k8s.io/kubernetes/pkg/api" ) -const TomcatPort int = 8080 -const TomcatName = "tomcat" - -var TomcatEndpoints = map[string]string{"c0": "1.1.1.1:18080", "c1": "2.2.2.2:18081"} - -const MysqlPort int = 3306 -const MysqlName = "mysql" - -var MysqlEndpoints = map[string]string{"c0": "1.1.1.1:13306", "c3": "2.2.2.2:13306"} - type sortedServices []api.Service func (s sortedServices) Len() int { @@ -130,14 +120,6 @@ func (h *EndpointsHandlerMock) ValidateEndpoints(t *testing.T, expectedEndpoints } } -func CreateServiceUpdate(op Operation, service *api.Service) ServiceUpdate { - return ServiceUpdate{Op: op, Service: service} -} - -func CreateEndpointsUpdate(op Operation, endpoints *api.Endpoints) EndpointsUpdate { - return EndpointsUpdate{Op: op, Endpoints: endpoints} -} - func TestNewServiceAddedAndNotified(t *testing.T) { fakeWatch := watch.NewFake() lw := fakeLW{