bucket

package
v1.51.1-0...-e186a28 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 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 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