Documentation ¶
Index ¶
Constants ¶
const ( MaxIDListSize = 100000 BloomGrowBy = 2 // double in size on each grow() BloomFpRate = 0.001 // Increasing means more duplicate requests, decreasing means bloom filter consumes more memory. )
const (
SnapshotSuffix = "-snapshot"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIMatch ¶
type APIMatch struct { GameID RiotID `json:"gameId"` SeasonID int `json:"seasonId"` GameCreation int64 `json:"gameCreation"` GameDuration int `json:"gameDuration"` Participants []struct { TeamID int `json:"teamId"` ChampionID RiotID `json:"championId"` Masteries []rawMastery `json:"masteries"` Runes []rawRune `json:"runes"` Stats struct { Win bool `json:"win"` Item0 int32 Item1 int32 Item2 int32 Item3 int32 Item4 int32 Item5 int32 Item6 int32 Kills int32 Deaths int32 Assists int32 LargestKillingSpree int32 LargestMultiKill int32 KillingSprees int32 LongestTimeSpentLiving int32 DoubleKills int32 TripleKills int32 QuadraKills int32 PentaKills int32 UnrealKills int32 TotalDamageDealt int32 MagicDamageDealt int32 PhysicalDamageDealt int32 TrueDamageDealt int32 LargestCriticalStrike int32 TotalDamageDealtToChampions int32 MagicDamageDealtToChampions int32 PhysicalDamageDealtToChampions int32 TrueDamageDealtToChampions int32 TotalHeal int32 TotalUnitsHealed int32 DamageSelfMitigated int32 DamageDealtToObjectives int32 DamageDealtToTurrets int32 VisionScore int32 TimeCCingOthers int32 TotalDamageTaken int32 MagicalDamageTaken int32 PhysicalDamageTaken int32 TrueDamageTaken int32 GoldEarned int32 GoldSpent int32 TurretKills int32 InhibitorKills int32 TotalMinionsKilled int32 NeutralMinionsKilled int32 NeutralMinionsKilledTeamJungle int32 NeutralMinionsKilledEnemyJungle int32 TotalTimeCrowdControlDealt int32 ChampLevel int32 VisionWardsBoughtInGame int32 SightWardsBoughtInGame int32 WardsPlaced int32 WardsKilled int32 FirstBloodKill bool FirstBloodAssist bool FirstTowerKill bool FirstTowerAssist bool FirstInhibitorKill bool FirstInhibitorAssist bool CombatPlayerScore int32 ObjectivePlayerScore int32 TotalPlayerScore int32 TotalScoreRank int32 } `json:"stats"` } ParticipantIdentities []struct { Player struct { AccountID RiotID `json:"accountId"` SummonerName string `json:"summonerName"` SummonerID RiotID `json:"summonerId"` ProfileIcon int `json:"profileIcon"` } `json:"player"` } Teams []struct { Bans []struct { ChampionID RiotID `json:"championId"` } `json:"bans"` } GameMode string `json:"gameMode"` MapID int `json:"mapId"` GameType string `json:"gameType"` }
APIMatch : Raw data returned from Riot's API. Converted to Match using ToMatch() function.
type ChampPack ¶
ChampPack : Low-level mapping struct used to convert between sparse RiotID's and dense packedChampID's. This struct keeps a direct mapping in memory and can convert between the two in a single array lookup, which provides roughly a 5.2x speedup in go1.7.1 (see packedarray_test.go benchmarks for experiment).
func NewChampPack ¶
NewChampPack : Return a new ChampPack instance with a max (packed) size of `count` and a maximum ID value of `maxID`. For example, NewChampPack(5, 10) means there will be at most five mappings added, with the max RiotID being 10.
func (*ChampPack) AddRiotID ¶
AddRiotID : Add a new Riot ID to the mapping. Returns the corresponding packedChampID.
func (*ChampPack) GetPacked ¶
GetPacked : Get a packedChampID for a previously-added RiotID. The boolean return value indicates whether the specified RiotID is known, and if not then the first value should not be trusted.
func (*ChampPack) GetUnpacked ¶
GetUnpacked : Get previously-added RiotID corresponding to a packedChampID. The boolean return value indicates whether the specified RiotID is known, and if not then the first value should not be trusted.
func (*ChampPack) PackedSize ¶
PackedSize : Returns the current number of champions packed in.
type IDList ¶
type IDList struct { Queue chan RiotID // contains filtered or unexported fields }
IDList : A queue-like data structure that only allows items to be added once; if an item has already been added then attempts to re-add it will be rejected. IDLists are safe to use concurrently.
func (*IDList) Add ¶
Add : Add a new item to the list if it hasn't been added before. Items are added in order and cannot be added to the same list twice. Note that `IDList` uses a bloom filter to track which elements have been added and some false positives occur, meaning that some items will be incorrectly blocked.
func (*IDList) Blacklist ¶
Blacklist : Add a new item to the blacklist. This is automatically called by Add() and shouldn't be called externally unless you want to blacklist *without* adding to the list.
func (*IDList) Blacklisted ¶ added in v0.1.2
Blacklisted : Returns a boolean indicating whether the specified ID exists in the list. Note that `IDList` uses a bloom filter to track which elements have been added so some false positives will occur.
type Match ¶
type Match struct { GameID RiotID `json:"gameId"` SeasonID int `json:"seasonId"` GameCreation int64 `json:"gameCreation"` GameDuration int `json:"gameDuration"` Participants []Participant Bans []RiotID GameMode string `json:"gameMode"` MapID int `json:"mapId"` GameType string `json:"gameType"` // contains filtered or unexported fields }
Match : Primary structure used to store match information. Generated from APIMatch's using ToMatch(), and can be encoded into a compact binary format for storage using Match.Bytes().
This struct stores all information related to an individual match, including summoner stats if Config.KeepStats is enabled.
func MakeMatch ¶
MakeMatch : Convert an encoded byte array back into a match. This is the inverse of Match.Bytes().
type MatchStore ¶
type MatchStore struct {
// contains filtered or unexported fields
}
MatchStore : Represents a persistent data store for match data. Implements a thin layer over a LevelDB instance and is capable of reading and writing match data to the database. All writes are serialized and its therefore safe to call `Add()` from multiple goroutines.
func NewMatchStore ¶
func NewMatchStore(filename string) *MatchStore
NewMatchStore : Create a new MatchStore that automatically records data and sync it to a snapshot instance.
func (*MatchStore) Add ¶
func (ms *MatchStore) Add(m Match)
Add : Queue up a new match to be written asynchronously.
func (*MatchStore) Close ¶
func (ms *MatchStore) Close()
Close : Clean up all related resources. No reads or writes are allowed after this function is called.
func (*MatchStore) Count ¶
func (ms *MatchStore) Count() int
Count : Returns the total number of records written to disk. Inaccurate unless Each() has been called at least once.
func (*MatchStore) Each ¶
func (ms *MatchStore) Each(fn func(*Match))
Each : Extract matches one by one.
type MatchSummary ¶
MatchSummary : summary information about matches from the API
type Pacer ¶
type Pacer struct {
// contains filtered or unexported fields
}
Pacer : Runs a function at a specified rate. In matchgrab this is being used for making API requests to Riot but I think its written generically enough that it could be repurposed for something else as well.
When a new pacer is created, a goroutine pool is also launched that monitor the input queue of functions to be executed (added w/ Each() function call). When executing functions from the queue, it will execute up to `maxSimultaneousRequests` functions simultaneously; if you want to avoid this simply set the value to 1 at initialization.
You can also pause execution for any period using the PauseFor() function.
func (*Pacer) PauseFor ¶
PauseFor : Pauses the pacer and will not start any new executions until the specified duration passes.
type PackedChampBooleanArray ¶
type PackedChampBooleanArray struct {
// contains filtered or unexported fields
}
func NewPackedChampBooleanArray ¶
func NewPackedChampBooleanArray(packer *ChampPack) *PackedChampBooleanArray
func (*PackedChampBooleanArray) Each ¶
func (pcba *PackedChampBooleanArray) Each(fn func(id RiotID, val bool))
type Participant ¶
type Participant struct { SummonerName string `json:"summonerName"` AccountID RiotID `json:"accountId"` ProfileIcon int `json:"profileIcon"` SummonerID RiotID `json:"summonerId"` ChampionID RiotID `json:"championId"` TeamID int `json:"teamId"` Winner bool `json:"winner"` Masteries []int32 Runes []int32 Items []int32 Stats *ParticipantStats }
Participant : Stores information about individual players, including stats if requested.
type ParticipantStats ¶ added in v0.2.0
type ParticipantStats struct { Kills int32 Deaths int32 Assists int32 LargestKillingSpree int32 LargestMultiKill int32 KillingSprees int32 LongestTimeSpentLiving int32 DoubleKills int32 TripleKills int32 QuadraKills int32 PentaKills int32 UnrealKills int32 TotalDamageDealt int32 MagicDamageDealt int32 PhysicalDamageDealt int32 TrueDamageDealt int32 LargestCriticalStrike int32 TotalDamageDealtToChampions int32 MagicDamageDealtToChampions int32 PhysicalDamageDealtToChampions int32 TrueDamageDealtToChampions int32 TotalHeal int32 TotalUnitsHealed int32 DamageSelfMitigated int32 DamageDealtToObjectives int32 DamageDealtToTurrets int32 VisionScore int32 TimeCCingOthers int32 TotalDamageTaken int32 MagicalDamageTaken int32 PhysicalDamageTaken int32 TrueDamageTaken int32 GoldEarned int32 GoldSpent int32 TurretKills int32 InhibitorKills int32 TotalMinionsKilled int32 NeutralMinionsKilled int32 NeutralMinionsKilledTeamJungle int32 NeutralMinionsKilledEnemyJungle int32 TotalTimeCrowdControlDealt int32 ChampLevel int32 VisionWardsBoughtInGame int32 SightWardsBoughtInGame int32 WardsPlaced int32 WardsKilled int32 FirstBloodKill bool FirstBloodAssist bool FirstTowerKill bool FirstTowerAssist bool FirstInhibitorKill bool FirstInhibitorAssist bool CombatPlayerScore int32 ObjectivePlayerScore int32 TotalPlayerScore int32 TotalScoreRank int32 }