indexer

package
v0.0.0-...-feac726 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 13 Imported by: 0

README

Indexer

An Indexer reads through rows in the stats databases and creates stats tables. For example counting up kills and deaths. We use indexers so that we don't have to query potentially 1000s of rows for every request.

Configuration

create or add to the existing collector settings.json You can set the path to this file with the environment variable KAGSTATS_CONFIG

{
	"databaseConnect": "root:password@tcp(127.0.0.1:3306)/kagstats"
	"indexer": {
		"batchSize": 100,
		"interval": "30s"
	}
}

The above are default values for batchSize and interval.

Alternatively environment variables can be used to configure the indexer. INDEXER_DB - the database connection string INDEXER_BATCHSIZE - the number of rows to process per an interval INDEXER_INTERVAL - the time between processing

Creating New Indexers

You can create a new indexer using this package. The table creation, row tracking and processing framework is all handled by the package function Process. All you need to do is implement KillsIndexer and call Run. See the basic indexer for a full example.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildInsert

func BuildInsert(indexer Indexer, tx *sql.Tx) (*sql.Stmt, error)

func BuildTable

func BuildTable(indexer Indexer) string

func CurrentIndex

func CurrentIndex(indexer Indexer, tx *sql.Tx) (int64, error)

func Equal

func Equal(a []interface{}, b []interface{}) bool

func GetIndexedTable

func GetIndexedTable(indexer Indexer) string

func Init

func Init(indexer Indexer, db *sqlx.DB) error

func Process

func Process(indexer Indexer, batchSize int, db *sqlx.DB) (int, error)

func ReadConfig

func ReadConfig() (configs.Config, error)

func Run

func Run(indexer Indexer) error

func SkipKill

func SkipKill(kill models.Kill, db *sqlx.DB) bool

func UnprocessedRows

func UnprocessedRows(indexer Indexer, batchSize int, tx *sql.Tx) (int64, *sql.Rows, error)

Types

type Index

type Index struct {
	Keys     []interface{}
	Counters map[string]int
}

func (Index) Add

func (a Index) Add(b Index) error

type IndexKey

type IndexKey struct {
	Name   string
	Table  string
	Column string
	Type   string
}

type Indexer

type Indexer interface {
	Name() string
	Version() int

	Keys() []IndexKey
	Counters() []string
}

type KillsIndexer

type KillsIndexer interface {
	Indexer
	Index(kill Kill) []Index
}

type MapVotesIndexer

type MapVotesIndexer interface {
	Indexer
	Index(votes MapVotes) []Index
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL