worker

package
v0.0.0-...-9573598 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregatedDigestEmailJob

func AggregatedDigestEmailJob[T logging.ChainableErrorOrWarnLogger[T]](
	dateAnalyzed time.Time,
	store *storage.Store,
	logger T,
	emailService oddmail.EmailService,
	addressBook email.AddressBook,
) error

AggregatedDigestEmailJob is the handler for the AggregatedDigestEmailJob which sends a daily digest email containing all analyzed audits from the audit period

func CreateModelStatusJobInBatch

func CreateModelStatusJobInBatch[T logging.ChainableErrorOrWarnLogger[T]](logger T, w *Worker, batch *faktory.Batch, plan *models.ModelPlan) error

func CreateModelStatusUpdateBatch

func CreateModelStatusUpdateBatch[T logging.ChainableErrorOrWarnLogger[T]](logger T, w *Worker, cl *faktory.Client, modelPlans []*models.ModelPlan) error

func CreateTranslatedAuditBatch

func CreateTranslatedAuditBatch[T logging.ChainableErrorOrWarnLogger[T]](w *Worker, logger T, cl *faktory.Client, queueObjects []*models.TranslatedAuditQueue) error

CreateTranslatedAuditBatch Creates a new batch job using the provided faktory client it will create a translated audit job for each provided queueObject

func FaktoryLoggerMiddleware

func FaktoryLoggerMiddleware() faktory_worker.MiddlewareFunc

FaktoryLoggerMiddleware is a Faktory middleware that adds a FaktoryLogger to the context with standard Faktory fields

func JobWithPanicProtection

func JobWithPanicProtection(jobFunc faktory_worker.Perform) faktory_worker.Perform

JobWithPanicProtection wraps a faktory Job in a wrapper function that will return an error instead of stopping the application.

func NewDBConfig

func NewDBConfig() storage.DBConfig

NewDBConfig returns a DBConfig struct with values from appconfig

func QueueTranslatedAuditJob

func QueueTranslatedAuditJob[T logging.ChainableErrorOrWarnLogger[T]](w *Worker, logger T, batch *faktory.Batch, queueObj *models.TranslatedAuditQueue) (*models.TranslatedAuditQueue, error)

QueueTranslatedAuditJob takes a given queueObj and creates a job as part of the provided batch

func RecoverFaktoryJobPanicAndLogError

func RecoverFaktoryJobPanicAndLogError(ctx context.Context, returnedError *error)

Types

type FaktoryLogger

type FaktoryLogger struct {
	logging.ZapLogger
	// contains filtered or unexported fields
}

func FaktoryLoggerFromContext

func FaktoryLoggerFromContext(ctx context.Context) *FaktoryLogger

FaktoryLoggerFromContext retrieves the FaktoryLogger from the context, or creates a new one if not present

func NewFaktoryLogger

func NewFaktoryLogger(logger *zap.Logger) *FaktoryLogger

NewFaktoryLogger creates a new FaktoryLogger from a zap.Logger

func (*FaktoryLogger) DecorateWithJobInfo

func (l *FaktoryLogger) DecorateWithJobInfo() *FaktoryLogger

DecorateWithJobInfo adds faktory job info fields to the logger Its intended to be used in the initial wrapper stage

func (*FaktoryLogger) ErrorOrWarn

func (l *FaktoryLogger) ErrorOrWarn(msg string, fields ...zap.Field)

func (*FaktoryLogger) IsFinalAttempt

func (l *FaktoryLogger) IsFinalAttempt() bool

func (*FaktoryLogger) Named

func (l *FaktoryLogger) Named(s string) *FaktoryLogger

func (*FaktoryLogger) ShouldError

func (l *FaktoryLogger) ShouldError() bool

ShouldError returns true if the job is on its final attempt if not, it returns false

func (*FaktoryLogger) With

func (l *FaktoryLogger) With(fields ...zap.Field) *FaktoryLogger

func (*FaktoryLogger) WithOptions

func (l *FaktoryLogger) WithOptions(opts ...zap.Option) *FaktoryLogger

type JobWrapper

type JobWrapper struct {
	Name string
	Job  func(context.Context, ...interface{}) error
}

type TestConfigs

type TestConfigs struct {
	DBConfig   storage.DBConfig
	LDClient   *ld.LDClient
	Logger     *zap.Logger
	UserInfo   *models.UserInfo
	Store      *storage.Store
	S3Client   *s3.S3Client
	PubSub     *pubsub.ServicePubSub
	Principal  *authentication.ApplicationPrincipal
	Context    context.Context
	OktaClient oktaapi.Client
}

TestConfigs is a struct that contains all the dependencies needed to run a test

func GetDefaultTestConfigs

func GetDefaultTestConfigs() *TestConfigs

GetDefaultTestConfigs returns a TestConfigs struct with all the dependencies needed to run a test

func (*TestConfigs) GetDefaults

func (tc *TestConfigs) GetDefaults()

GetDefaults sets the dependencies for the TestConfigs struct that will remain constant across the suite The principal needs to be set before every test as the user account is removed between tests

type Worker

type Worker struct {
	Store         *storage.Store
	Environment   appconfig.Environment
	EmailService  oddmail.EmailService
	AddressBook   email.AddressBook
	Connections   int
	ProcessJobs   bool
	OktaAPIClient oktaapi.Client
}

Worker is a struct that contains all the dependencies to run worker functions

func (*Worker) AggregatedDigestEmailJob

func (w *Worker) AggregatedDigestEmailJob(ctx context.Context, args ...interface{}) error

AggregatedDigestEmailJob will generate and send an email based on all models changed in the audit period

func (*Worker) AnalyzedAuditBatchJob

func (w *Worker) AnalyzedAuditBatchJob(ctx context.Context, args ...interface{}) error

AnalyzedAuditBatchJob batches all the daily AnalyzedAuditJobs. When all are complete it will fire a callback args[0] date

func (*Worker) AnalyzedAuditBatchJobSuccess

func (w *Worker) AnalyzedAuditBatchJobSuccess(ctx context.Context, args ...interface{}) error

AnalyzedAuditBatchJobSuccess is the callback function for AnalyzedAuditBatchJob args[0] date

func (*Worker) AnalyzedAuditJob

func (w *Worker) AnalyzedAuditJob(ctx context.Context, args ...interface{}) error

AnalyzedAuditJob analyzes the given model and model relations on the specified date args[0] date, args[1] modelPlanID

func (*Worker) DigestCronJob

func (w *Worker) DigestCronJob(ctx context.Context, args ...interface{}) error

DigestCronJob is the job the cron schedule calls

func (*Worker) DigestEmailBatchJob

func (w *Worker) DigestEmailBatchJob(ctx context.Context, args ...interface{}) error

DigestEmailBatchJob is the batch job for DigestEmailJobs args[0] date

func (*Worker) DigestEmailBatchJobSuccess

func (w *Worker) DigestEmailBatchJobSuccess(ctx context.Context, args ...interface{}) error

DigestEmailBatchJobSuccess is the callback function forDigestEmailBatchJob args[0] date

func (*Worker) DigestEmailJob

func (w *Worker) DigestEmailJob(ctx context.Context, args ...interface{}) error

DigestEmailJob will generate and send an email based on a users favorited Models. args[0] date, args[1] userID

func (*Worker) ModelStatusUpdateBatchJob

func (w *Worker) ModelStatusUpdateBatchJob(ctx context.Context, args ...interface{}) error

ModelStatusUpdateBatchJob is the job the cron job initiates to check if models need a status update. It will batch all child jobs, and when complete it will fire a callback

func (*Worker) ModelStatusUpdateBatchJobSuccess

func (w *Worker) ModelStatusUpdateBatchJobSuccess(ctx context.Context, args ...interface{}) error

ModelStatusUpdateBatchJobSuccess is called when the model status update job has completed.

func (*Worker) ModelStatusUpdateCronJob

func (w *Worker) ModelStatusUpdateCronJob(ctx context.Context, args ...interface{}) error

ModelStatusUpdateCronJob is the job the cron schedule calls to check if models

func (*Worker) ModelStatusUpdateJob

func (w *Worker) ModelStatusUpdateJob(ctx context.Context, args ...interface{}) (returnedError error)

ModelStatusUpdateJob is the job to check if a model should be updated, and if so, it will send an email args[0] model_plan_id (UUID)

func (*Worker) RefreshOktaCronJob

func (w *Worker) RefreshOktaCronJob(ctx context.Context, args ...interface{}) error

RefreshOktaCronJob is the job the cron schedule to refresh okta token every 15 days

func (*Worker) TranslateAuditBatchJob

func (w *Worker) TranslateAuditBatchJob(ctx context.Context, args ...interface{}) error

TranslateAuditBatchJob batches all the TranslateAuditJobs. When all are complete it will fire a callback args are not currently being used.

func (*Worker) TranslateAuditBatchJobSuccess

func (w *Worker) TranslateAuditBatchJobSuccess(ctx context.Context, args ...interface{}) error

TranslateAuditBatchJobSuccess is the call back that gets called when the TranslatedAuditBatchJob Completes

func (*Worker) TranslateAuditCronJob

func (w *Worker) TranslateAuditCronJob(ctx context.Context, args ...interface{}) error

TranslateAuditCronJob is the job the cron schedule calls

func (*Worker) TranslateAuditJob

func (w *Worker) TranslateAuditJob(ctx context.Context, args ...interface{}) (returnedError error)

TranslateAuditJob is the job to translate an individual audit into an analyzed audit, and note that the translation is done in the processing table args[0] the id of the audit change (int, but float in faktory) args[0] the id of the queue (UUID)

func (*Worker) Work

func (w *Worker) Work()

Work creates, configures, and starts worker

Jump to

Keyboard shortcuts

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