Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Service constants ServiceMaxAttempts = 3 ServiceMaxRetries = 3 ServiceRetryInterval = time.Millisecond * 100 // Context keys ServiceContextAttemptKey = iota + 1 ServiceContextRetryKey )
View Source
const DefaultResponseFormat = ResponseFormatPlain
Variables ¶
View Source
var ResponseFormatStrings = []string{
"unknown",
"html",
"json",
"plain",
}
ResponseFormatStrings is a list of string representations of known response formats.
Functions ¶
This section is empty.
Types ¶
type ResponseError ¶
ResponseError represents a response error structure.
type ResponseFormat ¶
type ResponseFormat uint32
ResponseFormat represents a target response format.
const ( // Formats ResponseFormatUnknown ResponseFormat = iota ResponseFormatHtml ResponseFormatJson ResponseFormatPlain )
func ToResponseFormat ¶
func ToResponseFormat(v string) ResponseFormat
ToResponseFormat returns the ResponseFormat for a given string. If a match can not be made, ResponseFormatUnknown is returned.
func (ResponseFormat) String ¶
func (f ResponseFormat) String() string
String returns the string representation for a given response format. If the response format is not known the string representation of RepsonseFormatUnknown is returned instead.
type ServicePool ¶
type ServicePool interface { // AddService adds a new service to the pool for the given target URL. AddService(target targets.Target) error // GC starts the IP registry garbage collector and returns a stop // function to exit garbage collection loop; effectively stopping the // routine. GC() StopFn // HealthCheck starts a routine to passively track the health of the // targeted services. It returns a function that can be called to stop // the health checking routine. HealthCheck(interval time.Duration) StopFn // LoadBalancer returns a handler func that will balance requests across // the targeted services using the Round Robin strategy. Further, // requests are rate limited by IP address. LoadBalancer() http.HandlerFunc // SetResponseFormat sets the error response formatting for the service // pool. SetResponseFormat(errFmt ResponseFormat) }
ServicePool represents a pool of services for tracking and balancing requests on behalf of clients to the backend services.
func New ¶
func New(rate int64, rateCap int64) ServicePool
Click to show internal directories.
Click to hide internal directories.