objectdeletion

package
v1.9.0-rc Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ObjectMissing represents when there's no object with that particular name
	ObjectMissing = ObjectStatus(iota)
	// ObjectMultiSegment represents a multi segment object
	ObjectMultiSegment
	// ObjectSingleSegment represents a single segment object
	ObjectSingleSegment
	// ObjectActiveOrZombie represents either an object is being uploaded, deleted or it's a zombie
	ObjectActiveOrZombie
)

Variables

View Source
var (

	// Error is a general object deletion error.
	Error = errs.Class("object deletion")
)

Functions

func CreateObjectStates

func CreateObjectStates(ctx context.Context, requests []*ObjectIdentifier, pointers []*pb.Pointer, paths [][]byte) (map[string]*ObjectState, error)

CreateObjectStates creates the current object states.

func GroupPiecesByNodeID

func GroupPiecesByNodeID(pointers []*pb.Pointer) map[storj.NodeID][]storj.PieceID

GroupPiecesByNodeID returns a map that contains pieces with node id as the key.

Types

type Config

type Config struct {
	MaxObjectsPerRequest     int `help:"maximum number of requests per batch" default:"100"`
	ZombieSegmentsPerRequest int `help:"number of segments per request when looking for zombie segments" default:"3"`
}

Config defines configuration options for Service.

func (*Config) Verify

func (config *Config) Verify() errs.Group

Verify verifies configuration sanity.

type ObjectIdentifier

type ObjectIdentifier struct {
	ProjectID     uuid.UUID
	Bucket        []byte
	EncryptedPath []byte
}

ObjectIdentifier contains information about an object that are needed for delete operation.

func ParseSegmentPath

func ParseSegmentPath(rawPath []byte) (ObjectIdentifier, int64, error)

ParseSegmentPath parses a raw path and returns an object identifier from that path along with the path's segment index. example: <project-id>/01/<bucket-name>/<encrypted-path>

func (*ObjectIdentifier) Key

func (id *ObjectIdentifier) Key() string

Key returns a string concatenated by all object identifier fields plus 0. It's a unique string used to identify an object. It's not a valid key for retrieving pointers from metainfo database.

func (*ObjectIdentifier) SegmentPath

func (id *ObjectIdentifier) SegmentPath(segmentIndex int64) ([]byte, error)

SegmentPath returns a raw path for a specific segment index.

type ObjectState

type ObjectState struct {
	ObjectIdentifier

	LastSegment *pb.Pointer
	ZeroSegment *pb.Pointer

	OtherSegments []*pb.Pointer
}

ObjectState determines how an object should be handled during a delete operation. It also stores pointers related to an object.

func (*ObjectState) Status

func (state *ObjectState) Status() ObjectStatus

Status returns the current object status.

type ObjectStatus

type ObjectStatus byte

ObjectStatus is used to determine how to retrieve segment information from the database.

type PointerDB

type PointerDB interface {
	GetItems(ctx context.Context, paths [][]byte) ([]*pb.Pointer, error)
	UnsynchronizedGetDel(ctx context.Context, paths [][]byte) (deletedPaths [][]byte, _ []*pb.Pointer, _ error)
}

PointerDB stores pointers.

type Report

type Report struct {
	Deleted []*ObjectIdentifier
	Failed  []*ObjectIdentifier
}

Report represents the deleteion status report.

func GenerateReport

func GenerateReport(ctx context.Context, log *zap.Logger, requests []*ObjectIdentifier, deletedPaths [][]byte) Report

GenerateReport returns the result of a delete, success, or failure.

func (Report) HasFailures

func (r Report) HasFailures() bool

HasFailures returns wether a delete operation has failures.

type Service

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

Service implements the object deletion service

architecture: Service

func NewService

func NewService(log *zap.Logger, pointerDB PointerDB, config Config) (*Service, error)

NewService returns new instance of Service.

func (*Service) DeletePointers

func (service *Service) DeletePointers(ctx context.Context, requests []*ObjectIdentifier) (_ []*pb.Pointer, _ [][]byte, err error)

DeletePointers returns a list of pointers and their paths that are deleted. If a object is not found, we will consider it as a successful delete.

Jump to

Keyboard shortcuts

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