Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoServers is returned when no servers are configured or available. ErrNoServers = errors.New("httpset: no servers configured or available") )
Functions ¶
This section is empty.
Types ¶
type HTTPSet ¶
A HTTPSet is a wrapper around the serverset.Watch to handle making requests to a set of servers. It encapsulates a http.Client using a httpset.Transport that does all the balancing. This object is DEPRECATED, one should use Transport and build their own http.Clients.
type Transport ¶
type Transport struct {
Watcher
UseHTTPS bool // if scheme not specified, will use https
// BaseTransport is what's used after the url is rewritten to the correct host.
// If not set, http.DefaultTransport will be used.
BaseTransport http.RoundTripper
LastEvent time.Time
EventCount int
// contains filtered or unexported fields
}
Transport implements the http.RoundTripper interface loadbalancing over a set of hosts.
func NewTransport ¶
NewTransport creates a new Transport given the server set. Pass in nil and use SetEndpoints to balance over a fixed set of endpoints.
func (*Transport) Endpoints ¶
Endpoints returns the current endpoints for this service. This can be those set via the serverset.Watch or manually via SetEndpoints()
func (*Transport) Event ¶
func (t *Transport) Event() <-chan struct{}
Event returns the event channel. This channel will get an object whenever something changes with the list of endpoints. Mostly just a passthrough of the underlying watch event and used for testing.
func (*Transport) RotateEndpoint ¶
RotateEndpoint returns host:port for the endpoints in a round-robin fashion.
func (*Transport) RoundTrip ¶
RoundTrip is here to implement the http.RoundTripper interface so this can be used as Transport for an http.Client. It simply rewrites the host and passit it to http.DefaultTransport or t.BaseTransport if defined. The default transport does it's own connection pooling based on hostname.
func (*Transport) SetEndpoints ¶
SetEndpoints sets current list of endpoints. This will override the list returned by the serverset. An event by the serverset will override these values. This should be used to take advantage of the round robin features of this library without a serverset.Watch.

