controller

package
v0.0.0-...-7b40e99 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeBetweenRequests = time.Duration(3 * time.Millisecond)
)

Functions

func IsErrorResponse

func IsErrorResponse(response string) bool

func IsInvalidKeyResponse

func IsInvalidKeyResponse(response string) bool

func MakeNetworkGETRequest

func MakeNetworkGETRequest(targetURL string) ([]byte, error)

MakeNetworkGETRequest limits the throughput for network GET requests. This is to stop network io timeouts from my router's DNS that occured through too many network requests being initiated concurrently

This allows roughly one GET request to be initiated at any given time but does not wait for the response before allowing another to be generated

Types

type Cntr

type Cntr struct{}

func (Cntr) CallGetFriends

func (control Cntr) CallGetFriends(steamID string) ([]string, error)

CallGetFriends calls the steam web API to retrieve a list of friends (steam IDs) for a given user.

friendIDs, err := CallGetFriends(steamID)

func (Cntr) CallGetOwnedGames

func (control Cntr) CallGetOwnedGames(steamID string) (common.GamesOwnedResponse, error)

CallGetOwnedGames calls the steam web api to retrieve all of a user's owned games

ownedGamesResponse, err := CallGetOwnedGames(steamID)

func (Cntr) CallGetPlayerSummaries

func (control Cntr) CallGetPlayerSummaries(steamIDStringList string) ([]common.Player, error)

CallGetPlayerSummaries calls the steam web API to retrieve player summaries for a list of steamIDs. A maximum of 100 steamIDs can be handled and must be encoded like this: steamID5641,steamID245,steamID43,steamID5747

playerSummaries, err := CallGetPlayerSummaries(steamIDList)

func (Cntr) ConsumeFromJobsQueue

func (control Cntr) ConsumeFromJobsQueue() (<-chan amqp.Delivery, error)

func (Cntr) GetCrawlingStatsFromDataStore

func (control Cntr) GetCrawlingStatsFromDataStore(crawlID string) (common.CrawlingStatus, error)

func (Cntr) GetGameDetailsFromIDs

func (control Cntr) GetGameDetailsFromIDs(gameIDs []int) ([]common.BareGameInfo, error)

func (Cntr) GetGraphableDataFromDataStore

func (control Cntr) GetGraphableDataFromDataStore(steamID string) (dtos.GetGraphableDataForUserDTO, error)

func (Cntr) GetUserFromDataStore

func (control Cntr) GetUserFromDataStore(steamID string) (common.UserDocument, error)

GetUserFromDataStore gets a user from the datastore service

userFromDataStore, err := GetUserFromDataStore(steamID)

func (Cntr) GetUsernamesForSteamIDs

func (control Cntr) GetUsernamesForSteamIDs(steamIDs []string) (map[string]string, error)

func (Cntr) PublishToJobsQueue

func (control Cntr) PublishToJobsQueue(channel amqp.Channel, jobJSON []byte) error

PublishToJobsQueue publishes a job to the rabbitMQ queue

err := PublishToJobsQueue(job)

func (Cntr) SaveCrawlingStatsToDataStore

func (control Cntr) SaveCrawlingStatsToDataStore(currentLevel int, crawlingStatus common.CrawlingStatus) (bool, error)

func (Cntr) SaveProcessedGraphDataToDataStore

func (control Cntr) SaveProcessedGraphDataToDataStore(crawlID string, graphData common.UsersGraphData) (bool, error)

func (Cntr) SaveUserToDataStore

func (control Cntr) SaveUserToDataStore(saveUser dtos.SaveUserDTO) (bool, error)

SaveUserToDataStore sends a user to the datastore service to be saved

userWasSaved, err := SaveUserToDataStore(user)

func (Cntr) Sleep

func (control Cntr) Sleep(duration time.Duration)

type CntrInterface

type CntrInterface interface {
	// Steam web API related functions
	CallGetFriends(steamID string) ([]string, error)
	CallGetPlayerSummaries(steamIDList string) ([]common.Player, error)
	CallGetOwnedGames(steamID string) (common.GamesOwnedResponse, error)
	// RabbitMQ related functions
	PublishToJobsQueue(channel amqp.Channel, jobJSON []byte) error
	ConsumeFromJobsQueue() (<-chan amqp.Delivery, error)
	// Datastore related functions
	SaveUserToDataStore(dtos.SaveUserDTO) (bool, error)
	GetUserFromDataStore(steamID string) (common.UserDocument, error)
	SaveCrawlingStatsToDataStore(currentLevel int, crawlingStatus common.CrawlingStatus) (bool, error)
	GetCrawlingStatsFromDataStore(crawlID string) (common.CrawlingStatus, error)
	GetGraphableDataFromDataStore(steamID string) (dtos.GetGraphableDataForUserDTO, error)
	GetUsernamesForSteamIDs(steamIDs []string) (map[string]string, error)
	SaveProcessedGraphDataToDataStore(crawlID string, graphData common.UsersGraphData) (bool, error)
	GetGameDetailsFromIDs(gameIDs []int) ([]common.BareGameInfo, error)

	Sleep(duration time.Duration)
}

type MockCntrInterface

type MockCntrInterface struct {
	mock.Mock
}

MockCntrInterface is an autogenerated mock type for the MockCntrInterface type

func (*MockCntrInterface) CallGetFriends

func (_m *MockCntrInterface) CallGetFriends(steamID string) ([]string, error)

CallGetFriends provides a mock function with given fields: steamID

func (*MockCntrInterface) CallGetOwnedGames

func (_m *MockCntrInterface) CallGetOwnedGames(steamID string) (common.GamesOwnedResponse, error)

CallGetOwnedGames provides a mock function with given fields: steamID

func (*MockCntrInterface) CallGetPlayerSummaries

func (_m *MockCntrInterface) CallGetPlayerSummaries(steamIDList string) ([]common.Player, error)

CallGetPlayerSummaries provides a mock function with given fields: steamIDList

func (*MockCntrInterface) ConsumeFromJobsQueue

func (_m *MockCntrInterface) ConsumeFromJobsQueue() (<-chan amqp.Delivery, error)

ConsumeFromJobsQueue provides a mock function with given fields:

func (*MockCntrInterface) GetCrawlingStatsFromDataStore

func (_m *MockCntrInterface) GetCrawlingStatsFromDataStore(crawlID string) (common.CrawlingStatus, error)

GetCrawlingStatsFromDataStore provides a mock function with given fields: crawlID

func (*MockCntrInterface) GetGameDetailsFromIDs

func (_m *MockCntrInterface) GetGameDetailsFromIDs(gameIDs []int) ([]common.BareGameInfo, error)

GetGameDetailsFromIDs provides a mock function with given fields: gameIDs

func (*MockCntrInterface) GetGraphableDataFromDataStore

func (_m *MockCntrInterface) GetGraphableDataFromDataStore(steamID string) (dtos.GetGraphableDataForUserDTO, error)

GetGraphableDataFromDataStore provides a mock function with given fields: steamID

func (*MockCntrInterface) GetUserFromDataStore

func (_m *MockCntrInterface) GetUserFromDataStore(steamID string) (common.UserDocument, error)

GetUserFromDataStore provides a mock function with given fields: steamID

func (*MockCntrInterface) GetUsernamesForSteamIDs

func (_m *MockCntrInterface) GetUsernamesForSteamIDs(steamIDs []string) (map[string]string, error)

GetUsernamesForSteamIDs provides a mock function with given fields: steamIDs

func (*MockCntrInterface) PublishToJobsQueue

func (_m *MockCntrInterface) PublishToJobsQueue(channel amqp.Channel, jobJSON []byte) error

PublishToJobsQueue provides a mock function with given fields: channel, jobJSON

func (*MockCntrInterface) SaveCrawlingStatsToDataStore

func (_m *MockCntrInterface) SaveCrawlingStatsToDataStore(currentLevel int, crawlingStatus common.CrawlingStatus) (bool, error)

SaveCrawlingStatsToDataStore provides a mock function with given fields: currentLevel, crawlingStatus

func (*MockCntrInterface) SaveProcessedGraphDataToDataStore

func (_m *MockCntrInterface) SaveProcessedGraphDataToDataStore(crawlID string, graphData common.UsersGraphData) (bool, error)

SaveProcessedGraphDataToDataStore provides a mock function with given fields: crawlID, graphData

func (*MockCntrInterface) SaveUserToDataStore

func (_m *MockCntrInterface) SaveUserToDataStore(_a0 dtos.SaveUserDTO) (bool, error)

SaveUserToDataStore provides a mock function with given fields: _a0

func (*MockCntrInterface) Sleep

func (_m *MockCntrInterface) Sleep(duration time.Duration)

Sleep provides a mock function with given fields: duration

Jump to

Keyboard shortcuts

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