buckets

package
v1.77.1-rc Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: AGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBucketNotEmpty is returned when a caller attempts to change placement constraints.
	ErrBucketNotEmpty = errs.Class("bucket must be empty")
)

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Name      []byte
	CreatedAt time.Time
}

Bucket contains minimal bucket fields for metainfo protocol.

type DB

type DB interface {
	// CreateBucket creates a new bucket
	CreateBucket(ctx context.Context, bucket storj.Bucket) (_ storj.Bucket, err error)
	// GetBucket returns an existing bucket
	GetBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (bucket storj.Bucket, err error)
	// GetBucketPlacement returns with the placement constraint identifier.
	GetBucketPlacement(ctx context.Context, bucketName []byte, projectID uuid.UUID) (placement storj.PlacementConstraint, err error)
	// GetMinimalBucket returns existing bucket with minimal number of fields.
	GetMinimalBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (bucket Bucket, err error)
	// HasBucket returns if a bucket exists.
	HasBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (exists bool, err error)
	// GetBucketID returns an existing bucket id.
	GetBucketID(ctx context.Context, bucket metabase.BucketLocation) (id uuid.UUID, err error)
	// UpdateBucket updates an existing bucket
	UpdateBucket(ctx context.Context, bucket storj.Bucket) (_ storj.Bucket, err error)
	// DeleteBucket deletes a bucket
	DeleteBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (err error)
	// ListBuckets returns all buckets for a project
	ListBuckets(ctx context.Context, projectID uuid.UUID, listOpts storj.BucketListOptions, allowedBuckets macaroon.AllowedBuckets) (bucketList storj.BucketList, err error)
	// CountBuckets returns the number of buckets a project currently has
	CountBuckets(ctx context.Context, projectID uuid.UUID) (int, error)
	// IterateBucketLocations iterates through all buckets from some point with limit.
	IterateBucketLocations(ctx context.Context, projectID uuid.UUID, bucketName string, limit int, fn func([]metabase.BucketLocation) error) (more bool, err error)
}

DB is the interface for the database to interact with buckets.

architecture: Database

type Service

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

Service encapsulates operations around buckets.

func NewService

func NewService(bucketsDB DB, metabase *metabase.DB) *Service

NewService converts the provided db and metabase calls into a single DB interface.

func (*Service) UpdateBucket

func (buckets *Service) UpdateBucket(ctx context.Context, bucket storj.Bucket) (storj.Bucket, error)

UpdateBucket overrides the default UpdateBucket behaviour by adding a check against MetabaseDB to ensure the bucket is empty before attempting to change the placement constraint of a bucket. If the placement constraint is not being changed, then this additional check is skipped.

Jump to

Keyboard shortcuts

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