Documentation ¶
Index ¶
- Variables
- func ConnectLHLocations()
- func ConnectToLighthouseServer(address string, secure bool) pb.LighthouseServiceClient
- func CreateGCPCloudTask(projectID, locationID, queueID, url string, body []byte) (*taskspb.Task, error)
- func CreateMemRateLimiter(rate string) *mhttp.Middleware
- func CreateMongoClient(mongoURI string)
- func CreateMongoIndexes()
- func CreateRedisClient(url string) *libredis.Client
- func CreateRedisRateLimiter(rate string, prefix string, rClient *libredis.Client) *mhttp.Middleware
- func GetAllReportsCount() (int64, error)
- func HTTPRunReport(r ReportRequest)
- func InitFirebase()
- func JwtMiddleware(next http.Handler) http.Handler
- func RunScheduledReports(reportRunner ReportRunner) int
- func StdoutLoggingHandler(h http.Handler) http.Handler
- func TokenFromAuthHeader(r *http.Request) (string, error)
- type App
- func (a *App) Run(address string)
- func (a *App) RunScheduledReports(w http.ResponseWriter, r *http.Request)
- func (a *App) ScheduledReportDelete(w http.ResponseWriter, r *http.Request)
- func (a *App) ScheduledReportGet(w http.ResponseWriter, r *http.Request)
- func (a *App) ScheduledReportsGet(w http.ResponseWriter, r *http.Request)
- func (a *App) ScheduledReportsPost(w http.ResponseWriter, r *http.Request)
- func (a *App) SetupRoutes()
- type AppOption
- type AuditResult
- type GCPScheduler
- type GoScheduler
- type Location
- type Report
- type ReportRequest
- type ReportRunner
- type ScheduledReport
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultRateLimit = "10-M" EnableAdminAPIs = false LighthouseClient pb.LighthouseServiceClient LighthouseClients map[string]pb.LighthouseServiceClient ApiUrl string GCPProject = "" GCPRegion = "" GCPTaskQueue = "" Scheduler = "" Auth = "" )
View Source
var ( SmtpHost = "" SmtpPort = 465 SmtpUsername = "" SmtpPassword = "" FromEmail = "info@websu.io" )
View Source
var ( DB *mongo.Client DatabaseName = "websu" )
View Source
var FirebaseApp *firebase.App
Functions ¶
func ConnectLHLocations ¶
func ConnectLHLocations()
func ConnectToLighthouseServer ¶
func ConnectToLighthouseServer(address string, secure bool) pb.LighthouseServiceClient
func CreateGCPCloudTask ¶
func CreateMemRateLimiter ¶
func CreateMemRateLimiter(rate string) *mhttp.Middleware
func CreateMongoClient ¶
func CreateMongoClient(mongoURI string)
func CreateMongoIndexes ¶
func CreateMongoIndexes()
func CreateRedisClient ¶
func CreateRedisRateLimiter ¶
func GetAllReportsCount ¶
func HTTPRunReport ¶
func HTTPRunReport(r ReportRequest)
func InitFirebase ¶
func InitFirebase()
func RunScheduledReports ¶
func RunScheduledReports(reportRunner ReportRunner) int
Types ¶
type App ¶
func (*App) RunScheduledReports ¶
func (a *App) RunScheduledReports(w http.ResponseWriter, r *http.Request)
func (*App) ScheduledReportDelete ¶
func (a *App) ScheduledReportDelete(w http.ResponseWriter, r *http.Request)
func (*App) ScheduledReportGet ¶
func (a *App) ScheduledReportGet(w http.ResponseWriter, r *http.Request)
func (*App) ScheduledReportsGet ¶
func (a *App) ScheduledReportsGet(w http.ResponseWriter, r *http.Request)
func (*App) ScheduledReportsPost ¶
func (a *App) ScheduledReportsPost(w http.ResponseWriter, r *http.Request)
func (*App) SetupRoutes ¶
func (a *App) SetupRoutes()
type AuditResult ¶
type AuditResult struct { ID string `json:"id"` Title string `json:"title"` Description string `json:"description"` Score float32 `json:"score"` ScoreDisplayMode string `json:"scoreDisplayMode"` NumericValue float64 `json:"numericValue"` NumericUnit string `json:"numericUnit"` DisplayValue string `json:"DisplayValue"` }
type GCPScheduler ¶
func (GCPScheduler) RunReport ¶
func (g GCPScheduler) RunReport(sr ScheduledReport)
type GoScheduler ¶
type GoScheduler struct{}
func (GoScheduler) RunReport ¶
func (g GoScheduler) RunReport(sr ScheduledReport)
func (*GoScheduler) Start ¶
func (gs *GoScheduler) Start()
type Location ¶
type Location struct { ID primitive.ObjectID `json:"id" bson:"_id"` Name string `json:"name" bson:"name" example:"australia-southeast1"` DisplayName string `json:"display_name" bson:"display_name" example:"Sydney, AU"` Address string `json:"address" bson:"address" example:"8.8.8.8:50051"` // Flag to indicate whether TLS should be used Secure bool `json:"secure" bson:"secure"` Order int32 `json:"order" bson:"order"` Premium bool `json:"premium" bson:"premium"` CreatedAt time.Time `json:"created_at" bson:"created_at"` }
func GetAllLocations ¶
func GetLocationByName ¶
func NewLocation ¶
func NewLocation() *Location
func NewLocationWithID ¶
type Report ¶
type Report struct { ID primitive.ObjectID `json:"id" bson:"_id"` ReportRequest `bson:",inline"` LocationDisplay string `json:"location_display" bson:"location_display"` // RawJSON contains the lighthouse JSON result RawJSON string `json:"raw_json" bson:"raw_json"` CreatedAt time.Time `json:"created_at" bson:"created_at"` PerformanceScore float32 `json:"performance_score" bson:"performance_score"` AuditResults map[string]AuditResult `json:"audit_results" bson:"audit_results"` }
func GetReportByObjectIDHex ¶
func GetReports ¶
func NewReportFromRequest ¶
func NewReportFromRequest(rr *ReportRequest) *Report
type ReportRequest ¶
type ReportRequest struct { // Required parameter the URL of the website URL string `json:"url" bson:"url" example:"https://www.google.com"` // Optional parameter, possible values are desktop or mobile. If unset will default to desktop FormFactor string `json:"form_factor" bson:"form_factor" example:"desktop"` // Optional parameter, by default will be set to 1000 if omitted ThroughputKbps int64 `json:"throughput_kbps" bson:"thoughput_kbps" example:"50000"` // Optional parameter, default location will be used if not set Location string `json:"location" bson:"location" example:"australia-southeast1"` // Optional parameter, email adress to sent the report to Email string `json:"email,omitempty" bson:"email"` User string `json:"user,omitempty" bson:"user"` }
func (ReportRequest) Validate ¶
func (r ReportRequest) Validate() error
type ReportRunner ¶
type ReportRunner interface {
RunReport(sr ScheduledReport)
}
type ScheduledReport ¶
type ScheduledReport struct { ID primitive.ObjectID `json:"id" bson:"_id"` ReportRequest `bson:",inline"` Schedule string `json:"schedule" bson:"schedule" example:"daily"` LastRun time.Time `json:"last_run" bson:"last_run"` CreatedAt time.Time `json:"created_at" bson:"created_at"` }
func GetAllScheduledReports ¶
func GetAllScheduledReports() ([]ScheduledReport, error)
func GetScheduleReportsDueToRun ¶
func GetScheduleReportsDueToRun() ([]ScheduledReport, error)
func GetScheduledReportByObjectIDHex ¶
func GetScheduledReportByObjectIDHex(hex string) (ScheduledReport, error)
func NewScheduledReport ¶
func NewScheduledReport() *ScheduledReport
func (*ScheduledReport) Delete ¶
func (sr *ScheduledReport) Delete() error
func (*ScheduledReport) Insert ¶
func (sr *ScheduledReport) Insert() error
func (*ScheduledReport) Update ¶
func (sr *ScheduledReport) Update() error
func (ScheduledReport) Validate ¶
func (s ScheduledReport) Validate() error
Click to show internal directories.
Click to hide internal directories.