mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Cleanup proxy/config
This commit is contained in:
parent
7ce368ccd2
commit
142c5a963d
@ -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
|
||||
|
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user