scheduler

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CacheKeyF format string for normal sprintf use
	CacheKeyF = "campaign%d.tasks"

	// CacheKeyR format string for the redis Scan function
	CacheKeyR = "campaign*.tasks"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Database is a pointer to the database struct.
	Database *db.TridentDB

	// ProjectID is the Google Cloud Platform project ID
	ProjectID string

	// TopicID is the Pub/Sub topic ID used by the producer to publish tasks.
	TopicID string

	// SubscriptionID is the Pub/Sub subscription used by the consumer to pull
	// task results.
	SubscriptionID string

	// RedisURI is the URI to the Redis instance (used for storing the task schedule)
	RedisURI string

	// RedisPassword is the Redis password
	RedisPassword string
}

Options is used to configure a PubSubScheduler.

type PubSubScheduler

type PubSubScheduler struct {
	// contains filtered or unexported fields
}

PubSubScheduler implements the scheduler interface and produces/consumes to Google Cloud Pub/Sub.

func NewPubSubScheduler

func NewPubSubScheduler(opts Options) (*PubSubScheduler, error)

NewPubSubScheduler creates a PubSubScheduler given the provided Options. This call will attempt to ping the provided RedisURI and error if this connection fails.

func (*PubSubScheduler) ConsumeResults

func (s *PubSubScheduler) ConsumeResults() error

ConsumeResults will stream results from pub/sub and store them in the database. Valid results are written directly to the database and invalid results are batched by the db.StreamingInsertResults function.

func (*PubSubScheduler) ProduceTasks

func (s *PubSubScheduler) ProduceTasks()

ProduceTasks will poll the task schedule and publish tasks to pub/sub when the top task is ready.

func (*PubSubScheduler) Schedule

func (s *PubSubScheduler) Schedule(campaign db.Campaign) error

Schedule accepts a campaign and computes all required tasks based on the provided NotBefore, NotAfter, and ScheduleInterval values. Tasks are scheduled by continuously adding the ScheduleInterval to a running timestamp (starting at the NotBefore time). Tasks which would be scheduled after the NotAfter time are discarded.

Additionally, this scheduler prefers to schedule credential guesses for a single password at a time, allowing the maximum time to pass before guessing a given username again.

type Scheduler

type Scheduler interface {
	Schedule(db.Campaign) error
	ProduceTasks()
	ConsumeResults() error
}

Scheduler is an interface which wraps several scheduling functions together.

Jump to

Keyboard shortcuts

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