Documentation ¶
Index ¶
- Constants
- Variables
- func NewLocalLockSource() *localLockSource
- type Configs
- type LockSource
- type Manager
- type ManagerOption
- func WithBatchSize(n int) ManagerOption
- func WithConfigs(cfgs Configs) ManagerOption
- func WithEnabled(enabled []string) ManagerOption
- func WithFactories(f map[string]driver.UpdaterSetFactory) ManagerOption
- func WithGC(retention int) ManagerOption
- func WithInterval(interval time.Duration) ManagerOption
- func WithOutOfTree(outOfTree []driver.Updater) ManagerOption
- Bugs
Constants ¶
const (
DefaultInterval = time.Duration(30 * time.Minute)
)
Variables ¶
var DefaultBatchSize = runtime.GOMAXPROCS(0)
Functions ¶
func NewLocalLockSource ¶ added in v1.1.0
func NewLocalLockSource() *localLockSource
NewLocalLockSource provides locks backed by local concurrency primitives.
Types ¶
type Configs ¶
type Configs map[string]driver.ConfigUnmarshaler
type LockSource ¶ added in v0.4.2
type LockSource interface { TryLock(context.Context, string) (context.Context, context.CancelFunc) Lock(context.Context, string) (context.Context, context.CancelFunc) }
LockSource abstracts over how locks are implemented.
An online system needs distributed locks, offline use cases can use process-local locks.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager oversees the configuration and invocation of vulnstore updaters.
The Manager may be used in a one-shot fashion, configured to run background jobs, or both.
func NewManager ¶
func NewManager(ctx context.Context, store vulnstore.Updater, locks LockSource, client *http.Client, opts ...ManagerOption) (*Manager, error)
NewManager will return a manager ready to have its Start or Run methods called.
type ManagerOption ¶
type ManagerOption func(m *Manager)
ManagerOption specify optional configuration for a Manager. Defaults will be used where options are not provided to the constructor.
func WithBatchSize ¶
func WithBatchSize(n int) ManagerOption
WithBatchSize sets the max number of parallel updaters that will run during an update interval.
func WithConfigs ¶
func WithConfigs(cfgs Configs) ManagerOption
WithConfigs tells the Manager to configure each updater where a configuration is provided.
Configuration of individual updaters is delegated to updater/registry.go Note: this option is optimal when ran after WithEnabled option. However, this option has no strict depedency on others.
func WithEnabled ¶
func WithEnabled(enabled []string) ManagerOption
WithEnabled configures the Manager to only run the specified updater sets.
If enabled == nil all default updater sets will run (same as not providing this option to the constructor at all). If len(enabled) == 0 no default updater sets will run. If len(enabled) > 0 only provided updater sets will be ran.
func WithFactories ¶ added in v0.4.2
func WithFactories(f map[string]driver.UpdaterSetFactory) ManagerOption
WithFactories resets UpdaterSetFactories used by the Manager.
func WithGC ¶
func WithGC(retention int) ManagerOption
WithGC instructs the manager to run garbage collection at the end of an update interval.
The provided retention value informs the manager how many update operations to keep.
func WithInterval ¶
func WithInterval(interval time.Duration) ManagerOption
WithInterval configures the interval at which updaters will be ran. The manager runs all configured updaters during an interval. Setting this duration too low may cause missed update intervals.
func WithOutOfTree ¶
func WithOutOfTree(outOfTree []driver.Updater) ManagerOption
WithOutOfTree allows callers to provide their own out-of-tree updaters.
note: currently we will never configure the outOfTree updater factory. if this changes consider making this option a required to avoid missing configuration
Notes ¶
Bugs ¶
The API provided by localLockSource does not respect the parent context cancellation when waiting for a lock.