Skip to content

Commit 37d0ea0

Browse files
committed
collector: make task structs private to package
Signed-off-by: Aaron Delaney <[email protected]>
1 parent 8b776d1 commit 37d0ea0

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

collector/tasks.go

+10-11
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ func (t *TaskCollector) Update(ctx context.Context, ch chan<- prometheus.Metric)
8181
return nil
8282
}
8383

84-
func (t *TaskCollector) fetchTasks(_ context.Context) (TasksResponse, error) {
84+
func (t *TaskCollector) fetchTasks(_ context.Context) (tasksResponse, error) {
8585
u := t.u.ResolveReference(&url.URL{Path: "_tasks"})
8686
q := u.Query()
8787
q.Set("group_by", "none")
8888
q.Set("actions", actionFilter)
8989
u.RawQuery = q.Encode()
9090

91-
var tr TasksResponse
91+
var tr tasksResponse
9292
res, err := t.hc.Get(u.String())
9393
if err != nil {
9494
return tr, fmt.Errorf("failed to get data stream stats health from %s://%s:%s%s: %s",
@@ -118,27 +118,26 @@ func (t *TaskCollector) fetchTasks(_ context.Context) (TasksResponse, error) {
118118
return tr, err
119119
}
120120

121-
// TasksResponse is a representation of the Task management API.
122-
type TasksResponse struct {
123-
Tasks []TaskResponse `json:"tasks"`
121+
// tasksResponse is a representation of the Task management API.
122+
type tasksResponse struct {
123+
Tasks []taskResponse `json:"tasks"`
124124
}
125125

126-
// TaskResponse is a representation of the individual task item returned by task API endpoint.
126+
// taskResponse is a representation of the individual task item returned by task API endpoint.
127127
//
128128
// We only parse a very limited amount of this API for use in aggregation.
129-
type TaskResponse struct {
129+
type taskResponse struct {
130130
Action string `json:"action"`
131131
}
132132

133-
type AggregatedTaskStats struct {
133+
type aggregatedTaskStats struct {
134134
CountByAction map[string]int64
135135
}
136136

137-
func AggregateTasks(t TasksResponse) *AggregatedTaskStats {
137+
func AggregateTasks(t tasksResponse) aggregatedTaskStats {
138138
actions := map[string]int64{}
139139
for _, task := range t.Tasks {
140140
actions[task.Action]++
141141
}
142-
agg := &AggregatedTaskStats{CountByAction: actions}
143-
return agg
142+
return aggregatedTaskStats{CountByAction: actions}
144143
}

0 commit comments

Comments
 (0)