mirror of
https://github.com/pgsty/minio.git
synced 2026-07-19 20:20:25 +03:00
Improve object reuse for grid messages (#18940)
Allow internal types to support a `Recycler` interface, which will allow for sharing of common types across handlers. This means that all `grid.MSS` (and similar) objects are shared across in a common pool instead of a per-handler pool. Add internal request reuse of internal types. Add for safe (pointerless) types explicitly. Only log params for internal types. Doing Sprint(obj) is just a bit too messy.
This commit is contained in:
+17
-14
@@ -21,7 +21,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -131,22 +130,26 @@ func (c *muxClient) traceRoundtrip(ctx context.Context, t *tracer, h HandlerID,
|
||||
}
|
||||
// If the context contains a TraceParamsKey, add it to the trace path.
|
||||
v := ctx.Value(TraceParamsKey{})
|
||||
if p, ok := v.(*MSS); ok && p != nil {
|
||||
trace.Path += p.ToQuery()
|
||||
trace.HTTP.ReqInfo.Path = trace.Path
|
||||
} else if p, ok := v.(map[string]string); ok {
|
||||
m := MSS(p)
|
||||
// Should match SingleHandler.Call checks.
|
||||
switch typed := v.(type) {
|
||||
case *MSS:
|
||||
trace.Path += typed.ToQuery()
|
||||
case map[string]string:
|
||||
m := MSS(typed)
|
||||
trace.Path += m.ToQuery()
|
||||
trace.HTTP.ReqInfo.Path = trace.Path
|
||||
} else if v != nil {
|
||||
// Print exported fields as single request to path.
|
||||
obj := fmt.Sprintf("%+v", v)
|
||||
if len(obj) > 1024 {
|
||||
obj = obj[:1024] + "..."
|
||||
case *URLValues:
|
||||
trace.Path += typed.Values().Encode()
|
||||
case *NoPayload:
|
||||
case *Bytes:
|
||||
if typed != nil {
|
||||
trace.Path = fmt.Sprintf("%s?bytes=%d", trace.Path, len(*typed))
|
||||
}
|
||||
trace.Path = fmt.Sprintf("%s?req=%s", trace.Path, url.QueryEscape(obj))
|
||||
trace.HTTP.ReqInfo.Path = trace.Path
|
||||
case string:
|
||||
trace.Path = fmt.Sprintf("%s?%s", trace.Path, typed)
|
||||
default:
|
||||
}
|
||||
trace.HTTP.ReqInfo.Path = trace.Path
|
||||
|
||||
t.Publisher.Publish(trace)
|
||||
return resp, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user