monitor

package module
v0.0.0-...-bf4fff2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 18 Imported by: 0

README

GPU Price Monitor

I'll write something here... eventually

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecPuppeteer

func ExecPuppeteer(urls []string) (*map[string]string, error)

func GenerateResultsEmail

func GenerateResultsEmail(stockMap StockMap) (string, bool)

func GenerateUrl

func GenerateUrl(site Site, product Product, keyword string) (string, error)

func Hprintf

func Hprintf(format string, vv ...string) string

ensures all arguments to sprinf are properly escaped

func MonitorProducts

func MonitorProducts(w http.ResponseWriter, r *http.Request)

func NewFalse

func NewFalse() *bool

func SendMail

func SendMail(cfg *Config, subject string, msg string) error

func Uprintf

func Uprintf(format string, vv ...string) string

ensures all arguments to sprinf are properly escaped

Types

type Config

type Config struct {
	Environment string    `envconfig:"GOLANG_ENVIRONMENT"`
	SendEmails  *bool     `json:"sendEmails"`
	Sites       []Site    `json:"sites"`
	Products    []Product `json:"products"`
	Mail        Mail      `json:"mail"`
}

func LoadConfig

func LoadConfig() (*Config, error)

func (Config) GetJobs

func (cfg Config) GetJobs() ([]interface{}, error)

func (*Config) Merge

func (dest *Config) Merge(ss ...Config) error

a simple merge function that applies each field value on top of dest, or the value of the previous Config in the array zero and nil values are not overwritten

type JobContext

type JobContext struct {
}

type KeywordScrapeFunc

type KeywordScrapeFunc = func(PriceCheckJob) []Model

a function that is responsible for scraping one keyword query for a given job

type Mail

type Mail struct {
	To       []string
	From     string `json:"from"`
	Password string `json:"password"`
}

type Model

type Model struct {
	Url    string
	Number string
	Price  float32
	Error  error
}

a struct to hold quantity/price information for a specific model of a product

func QueryBestBuy

func QueryBestBuy(j PriceCheckJob) []Model

func QueryMicroCenter

func QueryMicroCenter(j PriceCheckJob) []Model

func QueryNewegg

func QueryNewegg(j PriceCheckJob) []Model

func QueryWalMart

func QueryWalMart(j PriceCheckJob) []Model

type ModelMap

type ModelMap map[string]float32

func ToModelMap

func ToModelMap(models []Model) (ModelMap, error)

converts the list to a map. We don't reduce by price, because the model slice should already be price-reduced

func (ModelMap) AddModel

func (modelMap ModelMap) AddModel(modelNumber string, price float32)

add a model by either inserting a new one, or comparing with the price of an existing model in the map

func (ModelMap) AddModels

func (modelMap ModelMap) AddModels(models []Model)

adds a range of models

type PriceCheckJob

type PriceCheckJob struct {
	SiteName        string
	ProductName     string
	PriceThreshhold int
	Url             string
	PageContent     *string
}

type PriceCheckResponse

type PriceCheckResponse struct {
	Job    PriceCheckJob
	Error  error
	Models []Model
}

type Product

type Product struct {
	Name               string   `json:"name"`
	AdditionalKeywords []string `json:"additionalKeywords"`
	PriceThreshhold    int      `json:"priceThreshold"`
}

type ProductMap

type ProductMap map[string]ModelMap

type RequestMessage

type RequestMessage struct {
	ConfigOverrides *Config `json:"configOverrides"`
}

type Site

type Site struct {
	Name      string `json:"name"`
	UrlFormat string `json:"urlFormat"`
}

type StockMap

type StockMap map[string]ProductMap

func (StockMap) AddResult

func (m StockMap) AddResult(r PriceCheckResponse)

type WorkTask

type WorkTask func(interface{}) interface{}

type WorkerPool

type WorkerPool struct {
	WorkerCount int
	Results     chan interface{}

	JobCount int
	// contains filtered or unexported fields
}

func NewWorkerPool

func NewWorkerPool(workerCount int, jobs []interface{}, work WorkTask) *WorkerPool

func (WorkerPool) Start

func (pool WorkerPool) Start()

Jump to

Keyboard shortcuts

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