-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstatus.go
60 lines (52 loc) · 2.1 KB
/
status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package opendota
import (
"net/http"
"github.com/dghubble/sling"
)
func newStatusService(sling *sling.Sling) *StatusService {
return &StatusService{
sling: sling.Path("status"),
}
}
// StatusService provides a method for accessing OpenDota API stats.
type StatusService struct {
sling *sling.Sling
}
// Status represents the stats for the OpenDota API.
type Status struct {
UserPlayers int `json:"user_players"`
TrackedPlayers int `json:"tracked_players"`
MatchesLastDay int `json:"matches_last_day"`
MatchesLastHour int `json:"matches_last_hour"`
RetrieverMatchesLastDay int `json:"retriever_matches_last_day"`
ParsedMatchesLastDay int `json:"parsed_matches_last_day"`
RequestsLastDay int `json:"requests_last_day"`
APIHitsLastDay int `json:"api_hits_last_day"`
APIHitsUILastDay int `json:"api_hits_ui_last_day"`
FhQueue int `json:"fhQueue"`
GcQueue int `json:"gcQueue"`
MmrQueue int `json:"mmrQueue"`
Retriever []HostnameCounts `json:"retriever"`
APIPaths []HostnameCounts `json:"api_paths"`
LastAdded []MatchStatus `json:"last_added"`
LastParsed []MatchStatus `json:"last_parsed"`
LoadTimes map[string]int `json:"load_times"`
Health Health `json:"health"`
}
type HostnameCounts struct {
Hostname string `json:"hostname"`
Count string `json:"count"`
}
type MatchStatus struct {
MatchID int64 `json:"match_id"`
Duration int `json:"duration"`
StartTime int `json:"start_time"`
}
// Status returns the current status of the OpenDota API.
// https://docs.opendota.com/#tag/status%2Fpaths%2F~1status%2Fget
func (s *StatusService) Status() (Status, *http.Response, error) {
status := new(Status)
apiError := new(APIError)
resp, err := s.sling.New().Receive(status, apiError)
return *status, resp, relevantError(err, *apiError)
}