jobs

package
v0.0.0-...-5d45892 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeyCheckSTH is the name of the job
	KeyCheckSTH = "cron_check_sth"

	// InsecurePrefix can be prepended to the "connect_url" field to indicate that TLS verification should be disabled for a particular URL.
	// This is used from some older logs that appear to still be up, but have issues with their certificates.
	InsecurePrefix = "insecure-skip-verify-"
)
View Source
const (
	KeyGetEntries     = "get_entries"
	KeyUpdateMetadata = "update_metadata"

	MaxToRequest = 1024

	MaxToUpdate = 1024
)
View Source
const (
	StateActive = 0
	StateIgnore = 1
)
View Source
const (
	KeyUpdateLogs = "cron_update_logs"

	KnownLogsURL = "https://www.gstatic.com/ct/log_list/all_logs_list.json"
)
View Source
const (
	KeyNewLogMetadata = "new_log_metadata"
)

Variables

View Source
var (
	ErrImmediateReschedule = errors.New("commit tx, and reschedule ASAP")
	ErrDoNotReschedule     = errors.New("no need to reschedule, we are done")
)

Functions

func CheckLogSTH

func CheckLogSTH(qc *que.Client, logger *log.Logger, job *que.Job, tx *pgx.Tx) error

CheckLogSTH checks for new entries, and schedules a job to fetch them if needed

func GetEntries

func GetEntries(qc *que.Client, logger *log.Logger, job *que.Job, tx *pgx.Tx) error

func NewLogMetadata

func NewLogMetadata(qc *que.Client, logger *log.Logger, job *que.Job, tx *pgx.Tx) error

func RefreshMetadataForEntries

func RefreshMetadataForEntries(qc *que.Client, logger *log.Logger, job *que.Job, tx *pgx.Tx) error

func UpdateCTLogList

func UpdateCTLogList(qc *que.Client, logger *log.Logger, job *que.Job, tx *pgx.Tx) error

Types

type CTLog

type CTLog struct {
	URL            string `json:"url"`
	DisqualifiedAt int64  `json:"disqualified_at"`
	FinalSTH       *struct {
		TreeSize int64 `json:"tree_size"`
	} `json:"final_sth"`
}

type CheckSTHConf

type CheckSTHConf struct {
	// URL is used to lookup the record in the monitored_logs table
	URL  string
	TLDs []string `json:"tlds"`
}

CheckSTHConf is stored in the que_jobs table

type GetEntriesConf

type GetEntriesConf struct {
	URL        string
	Start, End uint64   // end is exclusive
	TLDs       []string `json:"tlds"`
}

type Handler

type Handler struct {
	PGXConnConfig *pgx.ConnConfig
	InitSQL       string
	WorkerCount   int
	WorkerMap     map[string]*JobConfig
	OnStart       func(qc *que.Client, pgxPool *pgx.ConnPool, logger *log.Logger) error
	Logger        *log.Logger
	QueueName     string
}

func (*Handler) WorkForever

func (h *Handler) WorkForever() error

type JobConfig

type JobConfig struct {
	F JobFunc

	// Debug logging
	VerboseLogging bool

	// One will only be called at once
	Singleton bool

	// Will be rescheduled upon success
	Duration time.Duration
	// contains filtered or unexported fields
}

func (*JobConfig) CloneWith

func (scw *JobConfig) CloneWith(qc *que.Client, logger *log.Logger) *JobConfig

func (*JobConfig) Run

func (scw *JobConfig) Run(job *que.Job) error

type JobFunc

type JobFunc func(qc *que.Client, logger *log.Logger, job *que.Job, tx *pgx.Tx) error

JobFunc should do a thing. Return either: nil => wrapper will schedule the next cron (if a cron), then commit the tx. ErrImmediateReschedule => wrapper will commit the tx, then try it again immediately. ErrDidNotReschedule => wrapper will rollback the tx, and if a cron, will not reschedule or retry. any other error => wrapper rollback the tx, and allow que to reschedule

type LogMetadataJobArgs

type LogMetadataJobArgs struct {
	CTLog CTLog
	TLDs  []string
}

Jump to

Keyboard shortcuts

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