jobs

package
v0.0.0-...-d236baf Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 38 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ColorSuccess = 3066993  // Green
	ColorError   = 15158332 // Red
)
View Source
const COUNT_CHECK_INTERVAL = 20
View Source
const DATA_DELETE_JOB = "USER_DATA_DELETE_JOB"
View Source
const EMBEDDINGS_JOB_NAME = "EMBEDDINGS_JOB"
View Source
const FREE_JOB_NAME = "FREE_CREDITS_JOB"
View Source
const HEALTH_JOB_NAME = "HEALTH_JOB"
View Source
const NSFW_CHECK_JOB_NAME = "NSFW_CHECK_JOB"
View Source
const NSFW_CHECK_OUTPUTS_LIMIT = 50
View Source
const OUTPUTS_LIMIT = 10
View Source
const PRUNE_OLDER_THAN = 5 * time.Minute

Prune messages older than this time

View Source
const PRUNE_OLD_QUEUE_JOB_NAME = "PRUNE_OLD_QUEUE_JOB"

Variables

This section is empty.

Functions

func CreateTestGeneration

func CreateTestGeneration(log Logger, apiKey string) error

Types

type JobLogger

type JobLogger struct {
	JobName string
}

func NewJobLogger

func NewJobLogger(jobName string) *JobLogger

func (*JobLogger) Errorf

func (j *JobLogger) Errorf(s string, args ...any)

func (*JobLogger) Infof

func (j *JobLogger) Infof(s string, args ...any)

func (*JobLogger) Warnf

func (j *JobLogger) Warnf(s string, args ...any)

type JobRunner

type JobRunner struct {
	Repo         *repository.Repository
	Redis        *database.RedisWrapper
	Ctx          context.Context
	Discord      *discord.DiscordHealthTracker
	Track        *analytics.AnalyticsService
	Stripe       *stripe.API
	S3           *s3.S3
	S3Img2Img    *s3.S3
	Qdrant       *qdrant.QdrantClient
	MQClient     queue.MQClient
	CLIP         *clip.ClipService
	AsynqClient  *asynq.Client
	SupabaseAuth *database.SupabaseAuth
	HTTP         *http.Client
}

func (*JobRunner) AddFreeCreditsToEligibleUsers

func (j *JobRunner) AddFreeCreditsToEligibleUsers(log Logger) error

func (*JobRunner) CheckSCWorkerHealth

func (j *JobRunner) CheckSCWorkerHealth(log Logger) error

CheckHealth cron job

func (*JobRunner) DeleteUserData

func (j *JobRunner) DeleteUserData(log Logger, dryRun bool) error

func (*JobRunner) GetAndSetStats

func (j *JobRunner) GetAndSetStats(log Logger) error

func (*JobRunner) GetGenerationOutputCount

func (j *JobRunner) GetGenerationOutputCount() (int, error)

func (*JobRunner) GetUpscaleOutputCount

func (j *JobRunner) GetUpscaleOutputCount() (int, error)

func (*JobRunner) GetVoiceoverOutputCount

func (j *JobRunner) GetVoiceoverOutputCount() (int, error)

func (*JobRunner) HandleOutputsWithNoEmbedding

func (j *JobRunner) HandleOutputsWithNoEmbedding(log Logger) error

func (*JobRunner) HandleOutputsWithNoNsfwCheck

func (j *JobRunner) HandleOutputsWithNoNsfwCheck(log Logger) (int, error)

func (*JobRunner) PruneOldQueueItems

func (j *JobRunner) PruneOldQueueItems(log Logger) error

PruneOldQueueItems cron job

func (*JobRunner) RefundOldGenerationCredits

func (j *JobRunner) RefundOldGenerationCredits(log Logger) error

func (*JobRunner) SendUserCleanNotification

func (j *JobRunner) SendUserCleanNotification(log Logger, success bool, bannedUsersDeleted, nonBannedUsersDeleted int, errorMsg string) error

func (*JobRunner) StartAutoUpscaleJob

func (j *JobRunner) StartAutoUpscaleJob(log Logger)

func (*JobRunner) SyncStripe

func (j *JobRunner) SyncStripe(log Logger) error

Sync stripe subscriptions with active user products

type Logger

type Logger interface {
	Infof(s string, args ...any)
	Errorf(s string, args ...any)
	Warnf(s string, args ...any)
}

Just wrap logger so we can include the job name without repeating it

type RequestBody

type RequestBody struct {
	Prompt     string `json:"prompt"`
	Width      int    `json:"width"`
	Height     int    `json:"height"`
	NumOutputs int    `json:"num_outputs"`
}

type ResponseBody

type ResponseBody struct {
	Outputs []struct {
		ID       string `json:"id"`
		URL      string `json:"url"`
		ImageURL string `json:"image_url"`
	} `json:"outputs"`
}

Jump to

Keyboard shortcuts

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