taskprocessor

package
v0.0.0-...-0a4988c Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FetchIGDBGamesTaskName task name for fetching games from igdb
	FetchIGDBGamesTaskName = "fetch_igdb_games"
)
View Source
const (
	// ProcessModerationTaskName task name for processing game moderation
	ProcessModerationTaskName = "process_moderation"
)
View Source
const (
	// UpdateGameInfoTaskName task name for updating trending index
	UpdateGameInfoTaskName = "update_game_info"
)
View Source
const (
	// UpdateTrendingIndexTaskName task name for updating trending index
	UpdateTrendingIndexTaskName = "update_trending_index"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GameFacade

type GameFacade interface {
	CreateCompany(ctx context.Context, company model.Company) (int32, error)
	UpdateGameTrendingIndex(ctx context.Context, gameID int32) error
}

GameFacade game facade interface

type IGDBAPIClient

type IGDBAPIClient interface {
	GetTopRatedGames(ctx context.Context, platformsIDs []int64, releasedAfter time.Time, minRatingsCount, minRating, limit int64) ([]igdbapi.TopRatedGames, error)
	GetImageByURL(ctx context.Context, imageURL, imageType string) (igdbapi.GetImageResp, error)
	GetGameInfoForUpdate(ctx context.Context, igdbID int64) (igdbapi.GameInfoForUpdate, error)
}

IGDBAPIClient igdb api client interface

type ModerationFacade

type ModerationFacade interface {
	ProcessModeration(ctx context.Context, gameID int32) error
}

ModerationFacade moderation facade interface

type S3Client

type S3Client interface {
	Upload(ctx context.Context, data io.ReadSeeker, contentType string, md map[string]string) (s3.UploadResult, error)
}

S3Client s3 store client interface

type Storage

type Storage interface {
	RunWithTx(ctx context.Context, f func(context.Context) error) error

	GetTask(ctx context.Context, name string) (model.Task, error)
	UpdateTask(ctx context.Context, task model.Task) error

	CreateGame(ctx context.Context, cgd model.CreateGameData) (id int32, err error)
	GetGameIDByIGDBID(ctx context.Context, igdbID int64) (id int32, err error)
	GetGameByID(ctx context.Context, id int32) (game model.Game, err error)
	UpdateGameIGDBInfo(ctx context.Context, id int32, ug model.UpdateGameIGDBData) error
	GetPlatforms(ctx context.Context) ([]model.Platform, error)
	CreateGenre(ctx context.Context, g model.Genre) (int32, error)
	GetGenres(ctx context.Context) ([]model.Genre, error)
	GetCompanies(ctx context.Context) ([]model.Company, error)
	GetGamesIDsAfterID(ctx context.Context, lastID int32, batchSize int) ([]int32, error)

	GetPendingModerationGameIDs(ctx context.Context, limit int) ([]model.ModerationIDGameID, error)
	SetModerationRecordsStatus(ctx context.Context, gameIDs []int32, status model.ModerationStatus) error
}

Storage db storage interface

type TaskProvider

type TaskProvider struct {
	// contains filtered or unexported fields
}

TaskProvider contains dependencies for tasks

func New

func New(log *zap.Logger, storage Storage, igdbClient IGDBAPIClient, s3Client S3Client, gameFacade GameFacade, moderationFacade ModerationFacade) *TaskProvider

New creates new TaskProvider

func (*TaskProvider) DoTask

func (tp *TaskProvider) DoTask(name string, taskFn func(ctx context.Context, settings model.TaskSettings) (newSettings model.TaskSettings, err error)) error

DoTask - runs task. name - name of a task to run. taskFn - function to be run: it accepts settings and returns updates settings

func (*TaskProvider) StartFetchIGDBGames

func (tp *TaskProvider) StartFetchIGDBGames() error

StartFetchIGDBGames starts fetch igdb games task

func (*TaskProvider) StartProcessModeration

func (tp *TaskProvider) StartProcessModeration() error

StartProcessModeration starts the process moderation task

func (*TaskProvider) StartUpdateGameInfo

func (tp *TaskProvider) StartUpdateGameInfo() error

StartUpdateGameInfo starts the update game info task

func (*TaskProvider) StartUpdateTrendingIndex

func (tp *TaskProvider) StartUpdateTrendingIndex() error

StartUpdateTrendingIndex starts the update trending index task

Directories

Path Synopsis
Package taskprocessor_mock is a generated GoMock package.
Package taskprocessor_mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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