Documentation
¶
Index ¶
- Constants
- Variables
- func NewK8sClient(conf Config) (*kubernetes.Clientset, error)
- func NewK8sStore(conf Config) (*k8sStore, error)
- func NewProxy(keyFunc KeyFunc, g Grouper, r Router, conf Config) http.Handler
- func NullHandler() http.Handler
- type Config
- type DBStore
- type Grouper
- type KeyFunc
- type Router
Constants ¶
View Source
const ( StateUnknown = iota StateHealthy StateUnhealthy )
View Source
const DECAY = 0.1
tracks last 10 samples (very fast)
Variables ¶
View Source
var ( ErrNoNodes = errors.New("no nodes available") ErrUnknownCommand = errors.New("unknown command") )
Functions ¶
func NewK8sClient ¶
func NewK8sClient(conf Config) (*kubernetes.Clientset, error)
func NewK8sStore ¶
func NullHandler ¶
Types ¶
type Config ¶
type Config struct {
DBurl string `json:"db_url"`
Listen string `json:"port"`
MgmtListen string `json:"mgmt_port"`
ShutdownTimeout int `json:"shutdown_timeout"`
ZipkinURL string `json:"zipkin_url"`
Nodes []string `json:"nodes"`
HealthcheckInterval int `json:"healthcheck_interval"`
HealthcheckEndpoint string `json:"healthcheck_endpoint"`
HealthcheckUnhealthy int `json:"healthcheck_unhealthy"`
HealthcheckHealthy int `json:"healthcheck_healthy"`
HealthcheckTimeout int `json:"healthcheck_timeout"`
MinAPIVersion *semver.Version `json:"min_api_version"`
// Kubernetes support
Namespace string `json:"k8s_namespace"`
LabelSelector string `json:"k8s_label_selector"`
TargetPort int `json:"target_port"`
Transport *http.Transport
}
type DBStore ¶
type DBStore interface {
io.Closer
Add(string) error
Delete(string) error
List() ([]string, error)
}
TODO put this somewhere better
type Grouper ¶
type Grouper interface {
// List returns a set of hosts that may be used to route a request
// for a given key.
List(key string) ([]string, error)
// Wrap allows adding middleware to the provided http.Handler.
Wrap(http.Handler) http.Handler
}
func NewAllGrouper ¶
NewAllGrouper returns a Grouper that will return the entire list of nodes that are being maintained, regardless of key. An 'AllGrouper' will health check servers at a specified interval, taking them in and out as they pass/fail and exposes endpoints for adding, removing and listing nodes.
type KeyFunc ¶
KeyFunc maps a request to a shard key, it may return an error if there are issues locating the shard key.
type Router ¶
type Router interface {
// Route will pick a node from the given set of nodes.
Route(nodes []string, key string) (string, error)
// InterceptResponse allows a Router to extract information from proxied
// requests so that it might do a better job next time. InterceptResponse
// should not modify the Response as it has already been received nor the
// Request, having already been sent.
InterceptResponse(req *http.Request, resp *http.Response)
// Wrap allows adding middleware to the provided http.Handler.
Wrap(http.Handler) http.Handler
}
func NewConsistentRouter ¶
Click to show internal directories.
Click to hide internal directories.