job_deleter

package
v0.0.0-...-dfed899 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

package job_deleter has functionality to delete jobs.

Requesting deletion marks the job as "deletion requested" in the database. This is relatively fast, and persistent. After this, the job is queued for actual deletion by a different goroutine.

At startup of the service the database is inspected and still-pending deletion requests are queued.

SPDX-License-Identifier: GPL-3.0-or-later

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeBroadcaster

type ChangeBroadcaster interface {
	// BroadcastJobUpdate sends the job update to SocketIO clients.
	BroadcastJobUpdate(jobUpdate api.EventJobUpdate)
}

type PersistenceService

type PersistenceService interface {
	FetchJob(ctx context.Context, jobUUID string) (*persistence.Job, error)
	FetchJobShamanCheckoutID(ctx context.Context, jobUUID string) (string, error)

	RequestJobDeletion(ctx context.Context, j *persistence.Job) error
	RequestJobMassDeletion(ctx context.Context, lastUpdatedMax time.Time) ([]string, error)

	// FetchJobsDeletionRequested returns the UUIDs of to-be-deleted jobs.
	FetchJobsDeletionRequested(ctx context.Context) ([]string, error)
	DeleteJob(ctx context.Context, jobUUID string) error

	RequestIntegrityCheck()
}

type Service

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

Service can mark jobs as "deletion requested", as well as delete those jobs in a background goroutine.

func NewService

func NewService(
	persist PersistenceService,
	storage Storage,
	changeBroadcaster ChangeBroadcaster,
	shaman Shaman,
) *Service

NewService constructs a new job deletion service. `shaman` can be nil if Shaman checkouts shouldn't be erased.

func (*Service) QueueJobDeletion

func (s *Service) QueueJobDeletion(ctx context.Context, job *persistence.Job) error

func (*Service) QueueMassJobDeletion

func (s *Service) QueueMassJobDeletion(ctx context.Context, lastUpdatedMax time.Time) error

func (*Service) Run

func (s *Service) Run(ctx context.Context)

Run processes the queue of deletion requests. It starts by building up a queue of still-pending job deletions.

func (*Service) WhatWouldBeDeleted

func (s *Service) WhatWouldBeDeleted(job *persistence.Job) api.JobDeletionInfo

type Shaman

type Shaman interface {
	// IsEnabled returns whether this Shaman service is enabled or not.
	IsEnabled() bool

	// EraseCheckout deletes the symlinks and the directory structure that makes up the checkout.
	EraseCheckout(checkoutID string) error
}

type Storage

type Storage interface {
	// RemoveJobStorage removes from disk the directory for storing job-related files.
	RemoveJobStorage(ctx context.Context, jobUUID string) error
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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