Skip to content

Commit

Permalink
fixed lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
s0s01qp committed Jul 21, 2021
1 parent 84ca455 commit f5a87c6
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions controllers/gin/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/sinhashubham95/go-actuator/models"
)

// ConfigureHandlers is used to add the respective handler functions for the configured actuator endpoints
// to the gin engine.
func ConfigureHandlers(config *models.Config, router *gin.Engine) {
actuator := router.Group(config.Prefix)
for _, e := range config.Endpoints {
Expand Down
2 changes: 2 additions & 0 deletions controllers/nethttp/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/sinhashubham95/go-actuator/models"
)

// ConfigureHandlers is used to add the respective handler functions for the configured actuator endpoints
// to the net http server mux.
func ConfigureHandlers(config *models.Config, mux *http.ServeMux) {
for _, e := range config.Endpoints {
// now one by one add the handler of each endpoint
Expand Down
3 changes: 2 additions & 1 deletion controllers/nethttp/threaddump.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
"github.com/sinhashubham95/go-actuator/core"
)

func HandleThreadDump(writer http.ResponseWriter, request *http.Request) {
// HandleThreadDump is the handler to get the thread dump
func HandleThreadDump(writer http.ResponseWriter, _ *http.Request) {
body, err := core.GetThreadDump()
if err != nil {
// some error occurred
Expand Down
5 changes: 5 additions & 0 deletions core/httptrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
var httpTraceResultsMu sync.Mutex
var httpTraceResults []*models.HTTPTraceResult

// WrapFastHTTPHandler should be used to wrap the created handler function for fast HTTP based web servers,
// so that the requests to the same can be traced.
func WrapFastHTTPHandler(handler fasthttp.RequestHandler) fasthttp.RequestHandler {
return func(ctx *fasthttp.RequestCtx) {
// for each new request create a result and trace the request
Expand All @@ -38,6 +40,7 @@ func WrapFastHTTPHandler(handler fasthttp.RequestHandler) fasthttp.RequestHandle
}
}

// GINTracer is the middleware function to be used with the GIN engines for tracing the requests to it.
func GINTracer() gin.HandlerFunc {
return func(ctx *gin.Context) {
// for each new request create a result and trace the request
Expand All @@ -62,6 +65,8 @@ func GINTracer() gin.HandlerFunc {
}
}

// WrapNetHTTPHandler should be used to wrap the created handler function for net HTTP based web servers,
// so that the requests to the same can be traced.
func WrapNetHTTPHandler(handler http.HandlerFunc) http.HandlerFunc {
return func(writer http.ResponseWriter, request *http.Request) {
// for each new request create a result and trace the request
Expand Down
1 change: 1 addition & 0 deletions core/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"runtime"
)

// Set of linked build time variables for providing relevant information for the application
var (
BuildStamp string
GitCommitAuthor string
Expand Down
2 changes: 1 addition & 1 deletion models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (config *Config) Validate() {
}
for _, endpoint := range config.Endpoints {
if !IsValidEndpoint(endpoint) {
panic(errors.New(fmt.Sprintf("invalid endpoint %d provided", endpoint)))
panic(fmt.Errorf("invalid endpoint %d provided", endpoint))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions models/endpoints.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package models

// Endpoints enumeration
const (
Env = iota
HTTPTrace
Expand Down
2 changes: 2 additions & 0 deletions models/httpTrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type HTTPStatusRecorder struct {
StatusCode int
}

// WriteHeader saves an HTTP response header with the provided
// status code.
func (r *HTTPStatusRecorder) WriteHeader(statusCode int) {
r.StatusCode = statusCode
r.ResponseWriter.WriteHeader(statusCode)
Expand Down
4 changes: 4 additions & 0 deletions models/memStats.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package models

// BySizeElement reports per-size class allocation statistics.
// BySize[N] gives statistics for allocations of size S where
// BySize[N-1].Size < S ≤ BySize[N].Size.
// This does not report allocations larger than BySize[60].Size.
type BySizeElement struct {
// Size is the maximum byte size of an object in this
// size class.
Expand Down

0 comments on commit f5a87c6

Please sign in to comment.