bucket

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2019 License: MIT Imports: 13 Imported by: 1

README

NaveOSS Bucket Module

The bucket module is a very simple interface to different storage providers. The bucket module is design in a key type design where the key is used to locate the data on the storage provider.

Why

Simplicity is the motivation of the Bucket module. By providing the wrapper for each of the supported storage providers importing applications can maintain a simple list of "active" Buckets. Allowing quick & easy read/write/delete without having to worry about where the file is hosted, what API to use, or even the real name of the file.

Interface

type Bucket interface {
	Name() string
	Delete(key string) error
	Write(key string, r io.ReadSeeker) error
	ReadCloser(key string) (io.ReadCloser, error)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInterfaceNotSupported = errors.New("Interface exists but does not function with this Bucket Type")
	BucketDebugLog           = false
)

Functions

This section is empty.

Types

type Bucket

type Bucket interface {

	// Name provides an identifier that can be used in keys and maps to identify the instance
	Name() string

	// Delete removes the data represented by key from the bucket's storage.
	// Success returns err == nil,
	// If err != null the state of the object in the storage is unknown. Verification of the state
	// needs to occur
	Delete(key string) error

	// Write copies the data from a ReadSeeker to the key that represents the data.
	Write(key string, r io.Reader) error

	// ReadCloser opens a ReadCloser for the data represented by key.
	ReadCloser(key string) (io.ReadCloser, error)
}

Bucket provides an API to read/write/delete files in storage regardless of the underlying storage type.

func NewBucketFromDSN

func NewBucketFromDSN(name string, DSN string, Auth string) (Bucket, error)

NewBucketFromDSN creates an object that implements the Bucket interface based on the DSN. Returns ErrInterfaceNotSupported if the DSN contains a type that isn't supported yet. If err != nil the bucket failed to create. See fileBucket, s3Bucket for DSN examples

Jump to

Keyboard shortcuts

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