Documentation ¶
Index ¶
- func HostURL(path string) func(*VascoClient)
- func Logger(logger *log.Entry) func(*VascoClient)
- func MyIP(ip string) func(*VascoClient)
- func Refresh(t time.Duration) func(*VascoClient)
- func VascoAddress(addr string) func(*VascoClient)
- type RequestCounter
- type Status
- type VascoClient
- func (vc *VascoClient) CL(handler http.HandlerFunc) http.HandlerFunc
- func (vc *VascoClient) CountQuery()
- func (vc *VascoClient) CountRequests(handler http.HandlerFunc) http.HandlerFunc
- func (vc *VascoClient) CountServerError()
- func (vc *VascoClient) CountUserError()
- func (vc *VascoClient) GetPort() string
- func (vc *VascoClient) GetProxyUrl(path string) url.URL
- func (vc *VascoClient) GetStatus() Status
- func (vc *VascoClient) LogRequests(handler http.HandlerFunc) http.HandlerFunc
- func (vc *VascoClient) MaxClients(handler http.HandlerFunc, n int) http.HandlerFunc
- func (vc *VascoClient) MyIP() (string, error)
- func (vc *VascoClient) Refresh() error
- func (vc *VascoClient) RefreshAndSetTimer()
- func (vc *VascoClient) Register(name, port, pattern, status string) error
- func (vc *VascoClient) Unregister() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HostURL ¶
func HostURL(path string) func(*VascoClient)
HostURL sets the address used for the Vasco Proxy -- internal calls between services.
func Logger ¶
func Logger(logger *log.Entry) func(*VascoClient)
Logger sets the logger from the suite available with logrus If not specified, vasco uses a default logger.
func MyIP ¶
func MyIP(ip string) func(*VascoClient)
MyIP tells vasco how to call you back; it's our own IP address. If not specified, it attempts to figure it out (but that's not going to work well inside a container).
func Refresh ¶
func Refresh(t time.Duration) func(*VascoClient)
Refresh sets the time between calls to the keepalive ping to vasco.
func VascoAddress ¶
func VascoAddress(addr string) func(*VascoClient)
VascoAddress lets you set the address that VascoClient should use to talk to the Vasco registry.
Types ¶
type RequestCounter ¶
type RequestCounter struct {
// contains filtered or unexported fields
}
func NewRequestCounter ¶
func NewRequestCounter(dur time.Duration) *RequestCounter
func (*RequestCounter) Count ¶
func (rc *RequestCounter) Count() int
func (*RequestCounter) N ¶
func (rc *RequestCounter) N() int
type Status ¶
type Status struct { StartTime time.Time `json:"starttime"` Uptime string `json:"uptime"` Revision string `json:"revision"` DeployTag string `json:"deploytag"` DeployType string `json:"configtype"` ConfigVersion string `json:"configversion"` IP string `json:"ip"` PID int `json:"pid"` Requests int `json:"requests"` UserErrors int `json:"usererrors"` ServerErrors int `json:"servererrors"` RequestsLastHour int `json:"requestslasthour"` RequestsLast5Min int `json:"requestslast5min"` // contains filtered or unexported fields }
func (*Status) FillStatus ¶
func (st *Status) FillStatus()
type VascoClient ¶
func New ¶
func New(options ...func(*VascoClient)) *VascoClient
New creates a new client and supports an arbitrary collection of initialization option functions (see above)
func (*VascoClient) CL ¶
func (vc *VascoClient) CL(handler http.HandlerFunc) http.HandlerFunc
CL is middleware that composes LogRequests and CountRequests
func (*VascoClient) CountQuery ¶
func (vc *VascoClient) CountQuery()
func (*VascoClient) CountRequests ¶
func (vc *VascoClient) CountRequests(handler http.HandlerFunc) http.HandlerFunc
CountRequests is middleware for standard handler functions
func (*VascoClient) CountServerError ¶
func (vc *VascoClient) CountServerError()
func (*VascoClient) CountUserError ¶
func (vc *VascoClient) CountUserError()
func (*VascoClient) GetPort ¶
func (vc *VascoClient) GetPort() string
Deprecated - always returns an empty string
func (*VascoClient) GetProxyUrl ¶
func (vc *VascoClient) GetProxyUrl(path string) url.URL
Return a URL ready for a Vasco proxy query (instead of going through the external load balancer, apps behind Vasco can talk to its proxy port directly).
func (*VascoClient) GetStatus ¶
func (vc *VascoClient) GetStatus() Status
func (*VascoClient) LogRequests ¶
func (vc *VascoClient) LogRequests(handler http.HandlerFunc) http.HandlerFunc
LogRequests is middleware
func (*VascoClient) MaxClients ¶
func (vc *VascoClient) MaxClients(handler http.HandlerFunc, n int) http.HandlerFunc
MaxClients is middleware that allows limiting the number of simultaneous requests to a given endpoint.
func (*VascoClient) MyIP ¶
func (vc *VascoClient) MyIP() (string, error)
MyIP returns the MyIP value or tries to figure it out.
func (*VascoClient) Refresh ¶
func (vc *VascoClient) Refresh() error
Refresh attempts to refresh the vascoClient with vasco. However, if we have never registered before, we need to do it for the first time. Similarly, if vasco has restarted or otherwise forgotten us, we need to re-register.
func (*VascoClient) RefreshAndSetTimer ¶
func (vc *VascoClient) RefreshAndSetTimer()
RefreshAndSetTimer is used to refresh vasco's keepalive, and then to set a time to wake itself up again.
func (*VascoClient) Register ¶
func (vc *VascoClient) Register(name, port, pattern, status string) error
Register calls the vasco registration endpoint.
func (*VascoClient) Unregister ¶
func (vc *VascoClient) Unregister() error
When we're shutting down, we want to unregister.