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"` Stats struct { Win bool `json:"win"` } `json:"stats"` } `json:"participants"` 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 }
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))