Documentation
¶
Overview ¶
Package worker contains all the logic or workers to execute queries to a DB It makes queries to a DB and returns how long it took to perform the operation The jobs are assigned deterministic based on the query (Hostname)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
parameters.QueryParams
// contains filtered or unexported fields
}
Job holds the information needed to execute a query. The query read from the file and the DB connection
func (Job) Execute ¶
Execute makes the query to the DB with the job params. Returns the Duration taken
func (Job) GetWorkerID ¶
GetWorkerID generates a number [0, numberWorkers-1] based on the host name the same hostname always gives the same worker (if the number of workers is the same)
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool contains a pool of worker goroutines that execute the jobs.
func CreatePool ¶
CreatePool creates a pool of workers of the given size and also the channels needed We need to pass the expected amount of results, so we can simplify the code as we will reserve a channel of the size of the results, hence we won't have a dead lock
func (Pool) WaitUntilDone ¶
WaitUntilDone blocks and waits until all jobs have been executed and returns a slice of Duration of all the successful results This method closes the input channels, so the worker goroutines will die when done.