buckets

package
v1.113.0-rc Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DirectionForward lists forwards from cursor, including cursor.
	DirectionForward = pb.ListDirection_FORWARD
	// DirectionAfter lists forwards from cursor, without cursor.
	DirectionAfter = pb.ListDirection_AFTER
)

Variables

View Source
var (
	// ErrBucket is an error class for general bucket errors.
	ErrBucket = errs.Class("bucket")

	// ErrNoBucket is an error class for using empty bucket name.
	ErrNoBucket = errs.Class("no bucket specified")

	// ErrBucketNotFound is an error class for non-existing bucket.
	ErrBucketNotFound = errs.Class("bucket not found")

	// ErrBucketAlreadyExists is used to indicate that bucket already exists.
	ErrBucketAlreadyExists = errs.Class("bucket already exists")

	// ErrConflict is used when a request conflicts with the state of a bucket.
	ErrConflict = errs.Class("bucket operation conflict")

	// ErrUnavailable is used when an operation is temporarily unavailable
	// due to a transient issue with the database's state.
	ErrUnavailable = errs.Class("bucket operation temporarily unavailable")

	// ErrLocked is used when an operation fails because a bucket has Object Lock enabled.
	ErrLocked = errs.Class("bucket has Object Lock enabled")
)
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 {
	ID                          uuid.UUID
	Name                        string
	ProjectID                   uuid.UUID
	CreatedBy                   uuid.UUID
	UserAgent                   []byte
	Created                     time.Time
	PathCipher                  storj.CipherSuite
	DefaultSegmentsSize         int64
	DefaultRedundancyScheme     storj.RedundancyScheme
	DefaultEncryptionParameters storj.EncryptionParameters
	Placement                   storj.PlacementConstraint
	Versioning                  Versioning
	ObjectLockEnabled           bool
}

Bucket contains information about a specific bucket.

type DB

type DB interface {
	// CreateBucket creates a new bucket
	CreateBucket(ctx context.Context, bucket Bucket) (_ Bucket, err error)
	// GetBucket returns an existing bucket
	GetBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (bucket Bucket, err error)
	// GetBucketPlacement returns with the placement constraint identifier.
	GetBucketPlacement(ctx context.Context, bucketName []byte, projectID uuid.UUID) (placement storj.PlacementConstraint, err error)
	// GetBucketVersioningState returns with the versioning state of the bucket.
	GetBucketVersioningState(ctx context.Context, bucketName []byte, projectID uuid.UUID) (versioningState Versioning, err error)
	// EnableBucketVersioning enables versioning for a bucket.
	EnableBucketVersioning(ctx context.Context, bucketName []byte, projectID uuid.UUID) error
	// SuspendBucketVersioning suspends versioning for a bucket.
	SuspendBucketVersioning(ctx context.Context, bucketName []byte, projectID uuid.UUID) error
	// GetMinimalBucket returns existing bucket with minimal number of fields.
	GetMinimalBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (bucket MinimalBucket, err error)
	// HasBucket returns if a bucket exists.
	HasBucket(ctx context.Context, bucketName []byte, projectID uuid.UUID) (exists bool, err error)
	// UpdateBucket updates an existing bucket
	UpdateBucket(ctx context.Context, bucket Bucket) (_ Bucket, err error)
	// UpdateUserAgent updates buckets user agent.
	UpdateUserAgent(ctx context.Context, projectID uuid.UUID, bucketName string, userAgent []byte) 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 ListOptions, allowedBuckets macaroon.AllowedBuckets) (bucketList List, 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 with specific page size.
	IterateBucketLocations(ctx context.Context, pageSize int, fn func([]metabase.BucketLocation) error) (err error)
	// GetBucketObjectLockEnabled returns whether a bucket has Object Lock enabled.
	GetBucketObjectLockEnabled(ctx context.Context, bucketName []byte, projectID uuid.UUID) (enabled bool, err error)
}

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

architecture: Database

type List added in v1.78.1

type List struct {
	More  bool
	Items []Bucket
}

List is a list of buckets.

type ListDirection added in v1.78.1

type ListDirection = pb.ListDirection

ListDirection specifies listing direction.

type ListOptions added in v1.78.1

type ListOptions struct {
	Cursor    string
	Direction ListDirection
	Limit     int
}

ListOptions lists objects.

func (ListOptions) NextPage added in v1.78.1

func (opts ListOptions) NextPage(list List) ListOptions

NextPage returns options for listing the next page.

type MinimalBucket added in v1.78.1

type MinimalBucket struct {
	Name      []byte
	CreatedBy uuid.UUID
	CreatedAt time.Time
	Placement storj.PlacementConstraint
}

MinimalBucket contains minimal bucket fields for metainfo protocol.

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 Bucket) (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.

type Versioning added in v1.91.2

type Versioning int

Versioning represents the versioning state of a bucket.

const (
	// VersioningUnsupported represents a bucket where versioning is not supported.
	VersioningUnsupported Versioning = 0
	// Unversioned represents a bucket where versioning has never been enabled.
	Unversioned Versioning = 1
	// VersioningEnabled represents a bucket where versioning is enabled.
	VersioningEnabled Versioning = 2
	// VersioningSuspended represents a bucket where versioning is currently suspended.
	VersioningSuspended Versioning = 3
)

func (Versioning) IsUnversioned added in v1.96.6

func (v Versioning) IsUnversioned() bool

IsUnversioned returns true if bucket state represents unversioned bucket.

Jump to

Keyboard shortcuts

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