piecedeletion

package
v0.35.1-rc Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package piecedeletion implements service for deleting pieces that combines concurrent requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FailPending

func FailPending(jobs Queue)

FailPending fails all the jobs in the queue.

Types

type Combiner

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

Combiner combines multiple concurrent deletion requests into batches.

func NewCombiner

func NewCombiner(parent context.Context, handler Handler, newQueue NewQueue) *Combiner

NewCombiner creates a new combiner.

func (*Combiner) Close

func (combiner *Combiner) Close()

Close shuts down all workers.

func (*Combiner) Enqueue

func (combiner *Combiner) Enqueue(node *pb.Node, job Job)

Enqueue adds a deletion job to the queue.

type Handler

type Handler interface {
	// Handle should call queue.PopAll until finished.
	Handle(ctx context.Context, node *pb.Node, queue Queue)
}

Handler handles piece deletion requests from a queue.

type Job

type Job struct {
	// Pieces are the pieces id-s that need to be deleted.
	Pieces []storj.PieceID
	// Resolve is for notifying the job issuer about the outcome.
	Resolve Promise
}

Job is a single of deletion.

type LimitedHandler

type LimitedHandler struct {
	Handler
	// contains filtered or unexported fields
}

LimitedHandler wraps handler with a concurrency limit.

func NewLimitedHandler

func NewLimitedHandler(handler Handler, limit int) *LimitedHandler

NewLimitedHandler wraps handler with a concurrency limit.

func (*LimitedHandler) Handle

func (handler *LimitedHandler) Handle(ctx context.Context, node *pb.Node, queue Queue)

Handle handles the job queue.

type LimitedJobs

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

LimitedJobs is a finalizable list of deletion jobs with a limit to how many jobs it can handle.

func NewLimitedJobs

func NewLimitedJobs(maxPiecesPerBatch int) *LimitedJobs

NewLimitedJobs returns a new limited job queue.

func (*LimitedJobs) PopAll

func (jobs *LimitedJobs) PopAll() (_ []Job, ok bool)

PopAll returns all the jobs in this list.

func (*LimitedJobs) TryPush

func (jobs *LimitedJobs) TryPush(job Job) bool

TryPush tries to add a job to the queue.

maxPiecesPerBatch < 0, means no limit

type NewQueue

type NewQueue func() Queue

NewQueue is a constructor func for queues.

type Promise

type Promise interface {
	// Success is called when the job has been successfully handled.
	Success()
	// Failure is called when the job didn't complete successfully.
	Failure()
}

Promise is for signaling to the deletion requests about the result.

type Queue

type Queue interface {
	// TryPush tries to push a new job to the queue.
	TryPush(job Job) bool
	// PopAll fetches all jobs in the queue.
	//
	// When there are no more jobs, the queue must stop accepting new jobs.
	PopAll() ([]Job, bool)
}

Queue is a queue for jobs.

Jump to

Keyboard shortcuts

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