Documentation ¶
Index ¶
Constants ¶
const ( // CacheControl header CacheControl = "Cache-Control" // Expires header Expires = "Expires" // EnvCacheEndpoint cache endpoint EnvCacheEndpoint = "SIDEKICK_CACHE_ENDPOINT" // EnvCacheAccessKey cache access key EnvCacheAccessKey = "SIDEKICK_CACHE_ACCESS_KEY" // EnvCacheSecretKey cache secret key EnvCacheSecretKey = "SIDEKICK_CACHE_SECRET_KEY" // EnvCacheBucket bucket to cache to. EnvCacheBucket = "SIDEKICK_CACHE_BUCKET" // EnvCacheMinSize minimum size of object that should be cached. EnvCacheMinSize = "SIDEKICK_CACHE_MIN_SIZE" // EnvCacheHealthCheckDuration - health check duration EnvCacheHealthCheckDuration = "SIDEKICK_CACHE_HEALTH_DURATION" )
const ( // LogMsgType for log messages LogMsgType = "LOG" // TraceMsgType for trace messages TraceMsgType = "TRACE" // DebugMsgType for debug output DebugMsgType = "DEBUG" )
Variables ¶
var BodyPlaceHolder = []byte("<BODY>")
BodyPlaceHolder returns a dummy body placeholder
Functions ¶
func SidekickMain ¶
func SidekickMain()
Types ¶
type Backend ¶
type Backend struct { Stats *BackendStats // contains filtered or unexported fields }
Backend entity to which requests gets load balanced.
func (*Backend) ErrorHandler ¶
ErrorHandler called by httputil.ReverseProxy for errors.
type BackendStats ¶
type BackendStats struct { sync.Mutex LastDowntime time.Duration CumDowntime time.Duration TotCalls int64 TotCallFailures int64 MinLatency time.Duration MaxLatency time.Duration CumLatency time.Duration Rx int64 Tx int64 UpSince time.Time DowntimeStart time.Time }
BackendStats holds server stats for backend
type ConnStats ¶
type ConnStats struct {
// contains filtered or unexported fields
}
ConnStats - statistics on backend
type HTTPRangeSpec ¶
type HTTPRangeSpec struct { // Does the range spec refer to a suffix of the object? IsSuffixLength bool // Start and end offset specified in range spec Start, End int64 }
HTTPRangeSpec represents a range specification as supported by S3 GET object request.
Case 1: Not present -> represented by a nil RangeSpec Case 2: bytes=1-10 (absolute start and end offsets) -> RangeSpec{false, 1, 10} Case 3: bytes=10- (absolute start offset with end offset unspecified) -> RangeSpec{false, 10, -1} Case 4: bytes=-30 (suffix length specification) -> RangeSpec{true, -30, -1}
func (*HTTPRangeSpec) GetLength ¶
func (h *HTTPRangeSpec) GetLength(resourceSize int64) (rangeLength int64, err error)
GetLength - get length of range
func (*HTTPRangeSpec) GetOffsetLength ¶
func (h *HTTPRangeSpec) GetOffsetLength(resourceSize int64) (start, length int64, err error)
GetOffsetLength computes the start offset and length of the range given the size of the resource
func (*HTTPRangeSpec) String ¶
func (h *HTTPRangeSpec) String(resourceSize int64) string
String returns stringified representation of range for a particular resource size.
type ResponseRecorder ¶
type ResponseRecorder struct { StatusCode int Flushed bool // Flushed is whether the Handler called Flush. // contains filtered or unexported fields }
ResponseRecorder returns a wrapped response writer to get underlying http.Response for cache handler.
func NewRecorder ¶
func NewRecorder() *ResponseRecorder
NewRecorder returns an initialized ResponseRecorder.
func (*ResponseRecorder) Flush ¶
func (rw *ResponseRecorder) Flush()
Flush calls underlying Flush method
func (*ResponseRecorder) Header ¶
func (rw *ResponseRecorder) Header() http.Header
Header needed for implementing "net/http".ResponseWriter
func (*ResponseRecorder) Result ¶
func (rw *ResponseRecorder) Result() *http.Response
Result returns the response generated by the handler. It blocks on the rw.ch until header some content has been written The returned Response will have at least its StatusCode, Header, Body
func (*ResponseRecorder) Write ¶
func (rw *ResponseRecorder) Write(buf []byte) (int, error)
Write implements http.ResponseWriter. The data in buf is written to the pipeWriter
func (*ResponseRecorder) WriteHeader ¶
func (rw *ResponseRecorder) WriteHeader(code int)
WriteHeader implements http.ResponseWriter.
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter StatusCode int // Response body should be logged LogBody bool TimeToFirstByte time.Duration StartTime time.Time // contains filtered or unexported fields }
ResponseWriter - is a wrapper to trap the http response status code.
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter) *ResponseWriter
NewResponseWriter - returns a wrapped response writer to trap http status codes for auditiing purposes.
func (*ResponseWriter) Flush ¶
func (lrw *ResponseWriter) Flush()
Flush - Calls the underlying Flush.
func (*ResponseWriter) Size ¶
func (lrw *ResponseWriter) Size() int
Size - reutrns the number of bytes written
func (*ResponseWriter) WriteHeader ¶
func (lrw *ResponseWriter) WriteHeader(code int)
WriteHeader - writes http status code
type ResponseWriterWrapper ¶
type ResponseWriterWrapper struct { http.ResponseWriter // contains filtered or unexported fields }
func (*ResponseWriterWrapper) WriteHeader ¶
func (w *ResponseWriterWrapper) WriteHeader(statusCode int)
type S3CacheClient ¶
S3CacheClient client to S3 cache storage.
type TraceInfo ¶
type TraceInfo struct { Type string `json:"type"` NodeName string `json:"nodename"` ReqInfo traceRequestInfo `json:"request"` RespInfo traceResponseInfo `json:"response"` CallStats traceCallStats `json:"stats"` }
TraceInfo - represents a trace record, additionally also reports errors if any while listening on trace.
func InternalTrace ¶
InternalTrace returns trace for sidekick http requests