cache

package
v0.0.0-...-b28e40e Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package cache saves data from the esports API into BigQuery.

Most users should use the update_esports_cache command instead of calling this API directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// EntityNamespace is the namespace used when saving datastore entities. By
	// default, this is constructed with the empty string, which represents the
	// default namespace. The parameter can be set immediately after calling New.
	EntityNamespace string
	// contains filtered or unexported fields
}

Cache represents a copy of the esports API data stored on Google Cloud. It is illegal to construct an instance directly. Use New to return a valid instance.

func New

func New(es *esports.Client, bq *bigquery.Uploader, ds *datastore.Client, doneEntity string) *Cache

New returns a Cache. doneEntity is the datastore entity name used to track whether a game was cached.

func (Cache) MaybeCreateDatasetAndTable

func (c Cache) MaybeCreateDatasetAndTable(ctx context.Context, table *bigquery.Table) error

MaybeCreateDatasetAndTable attempts to create the dataset containing the given table, as well as the table itself.

func (Cache) UploadNewGames

func (c Cache) UploadNewGames(ctx context.Context, league league.League, tournament string) error

UploadNewGames queries for all games in the given league and tournament title and uploads new games to BigQuery using the configured uploader. The table must exist. Call MaybeCreateDatasetAndTable to attempt the table creation.

type Game

type Game struct {
	// LeagueName is the league in which the game took place.
	LeagueName string

	// TournamentTitle is the title of the tournament where the game took place.
	TournamentTitle string

	// BracketName is the name of the bracket where the game took place.
	BracketName string

	// MatchName is the name of the match where the game took place. For example,
	// a match may consists of a best of five between two teams.
	MatchName string

	// Game is the summary view of the game.
	Game *apiclient.Match

	// GameTimeline is the timeline view of the game.
	GameTimeline *apiclient.MatchTimeline
}

Game is a serialized version of a specific game.

Jump to

Keyboard shortcuts

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