Do executes the request and returns response or error.
(providedCtx context.Context, transport Transport)
| 66 | |
| 67 | // Do executes the request and returns response or error. |
| 68 | func (r ClusterInfoRequest) Do(providedCtx context.Context, transport Transport) (*Response, error) { |
| 69 | var ( |
| 70 | method string |
| 71 | path strings.Builder |
| 72 | params map[string]string |
| 73 | ctx context.Context |
| 74 | ) |
| 75 | |
| 76 | if instrument, ok := r.Instrument.(Instrumentation); ok { |
| 77 | ctx = instrument.Start(providedCtx, "cluster.info") |
| 78 | defer instrument.Close(ctx) |
| 79 | } |
| 80 | if ctx == nil { |
| 81 | ctx = providedCtx |
| 82 | } |
| 83 | |
| 84 | method = "GET" |
| 85 | |
| 86 | if len(r.Target) == 0 { |
| 87 | return nil, errors.New("target is required and cannot be nil or empty") |
| 88 | } |
| 89 | |
| 90 | path.Grow(7 + 1 + len("_info") + 1 + len(strings.Join(r.Target, ","))) |
| 91 | path.WriteString("http://") |
| 92 | path.WriteString("/") |
| 93 | path.WriteString("_info") |
| 94 | path.WriteString("/") |
| 95 | path.WriteString(strings.Join(r.Target, ",")) |
| 96 | if instrument, ok := r.Instrument.(Instrumentation); ok { |
| 97 | instrument.RecordPathPart(ctx, "target", strings.Join(r.Target, ",")) |
| 98 | } |
| 99 | |
| 100 | params = make(map[string]string) |
| 101 | |
| 102 | if r.Pretty { |
| 103 | params["pretty"] = "true" |
| 104 | } |
| 105 | |
| 106 | if r.Human { |
| 107 | params["human"] = "true" |
| 108 | } |
| 109 | |
| 110 | if r.ErrorTrace { |
| 111 | params["error_trace"] = "true" |
| 112 | } |
| 113 | |
| 114 | if len(r.FilterPath) > 0 { |
| 115 | params["filter_path"] = strings.Join(r.FilterPath, ",") |
| 116 | } |
| 117 | |
| 118 | req, err := newRequest(method, path.String(), nil) |
| 119 | if err != nil { |
| 120 | if instrument, ok := r.Instrument.(Instrumentation); ok { |
| 121 | instrument.RecordError(ctx, err) |
| 122 | } |
| 123 | return nil, err |
| 124 | } |
| 125 |
nothing calls this directly
no test coverage detected