func New(config *Config) *LoadBalancer {
	config.setDefaults()
	return &LoadBalancer{
		apiAddr:      config.APIAddr,
		client:       config.Client,
		errorLog:     config.ErrorLog,
		namespace:    config.Namespace,
		retryDelay:   config.RetryDelay,
		service:      config.Service,
		syncInterval: config.SyncInterval,
		quit:         make(chan struct{}),
	}
}
New configures and returns a new *LoadBalancer. The LoadBalancer endpoints
list is populated by the Sync and StartBackgroundSync methods.
package endpoints
import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"net/url"
	"os"
	"strconv"
	"sync"
	"time"
)
const (
	endpointsPath      = "/api/v1/namespaces/%s/endpoints/%s"
	endpointsWatchPath = "/api/v1/watch/namespaces/%s/endpoints/%s"
)
const (
	defaultSyncInterval = 30 * time.Second
	defaultRetryDelay   = 5 * time.Second
)
var (
	DefaultAPIAddr   = "127.0.0.1:8001"
	DefaultNamespace = "default"
)
var (
	ErrNoEndpoints = errors.New("endpoints: no endpoints available")
	ErrMissingServiceName = errors.New("endpoints: missing service name")
)
type Endpoint struct {
	Host  string
	Port  string
	Ports map[string]string
}
type Config struct {
	APIAddr string
	Client *http.Client
	ErrorLog *log.Logger
	Namespace string
	RetryDelay time.Duration
	Service string
	SyncInterval time.Duration
}
type LoadBalancer struct {
	apiAddr      string
	client       *http.Client
	errorLog     *log.Logger
	namespace    string
	retryDelay   time.Duration
	service      string
	syncInterval time.Duration
	quit         chan struct{}
	wg           sync.WaitGroup
	mu              sync.RWMutex  
	currentEndpoint int
	endpoints       []Endpoint
}