bucket

package
v0.0.0-...-b4aeae5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package bucket is contains utilities for managing bucket-based backends

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyDeleted is returned when an already deleted
	// bucket is passed to Remove
	ErrAlreadyDeleted = errors.New("bucket already deleted")
)

Functions

func Join

func Join(path1, path2 string) string

Join path1 and path2

Like path.Join but does not clean the path - useful to preserve trailing /

func Split

func Split(absPath string) (bucket, bucketPath string)

Split takes an absolute path which includes the bucket and splits it into a bucket and a path in that bucket bucketPath

Types

type Cache

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

Cache stores whether buckets are available and their IDs

func NewCache

func NewCache() *Cache

NewCache creates an empty Cache

func (*Cache) Create

func (c *Cache) Create(bucket string, create CreateFn, exists ExistsFn) (err error)

Create the bucket with create() if it doesn't exist

If exists is set then if the bucket has been deleted it will call exists() to see if it still exists.

If f returns an error we assume the bucket was not created

func (*Cache) IsDeleted

func (c *Cache) IsDeleted(bucket string) bool

IsDeleted returns true if the bucket has definitely been deleted by us, false otherwise.

func (*Cache) MarkDeleted

func (c *Cache) MarkDeleted(bucket string)

MarkDeleted marks the bucket as being deleted

func (*Cache) MarkOK

func (c *Cache) MarkOK(bucket string)

MarkOK marks the bucket as being present

func (*Cache) Remove

func (c *Cache) Remove(bucket string, f func() error) error

Remove the bucket with f if it exists

If f returns an error we assume the bucket was not removed.

If the bucket has already been deleted it returns ErrAlreadyDeleted

type CreateFn

type CreateFn func() error

CreateFn should be passed to Create to make a bucket

type ExistsFn

type ExistsFn func() (found bool, err error)

ExistsFn should be passed to Create to see if a bucket exists or not

Jump to

Keyboard shortcuts

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