storage

package module
v0.0.0-...-d482c08 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

README

Storage

Cloud and filesystem storage driver

  • File system
  • Google Cloud Storage
  • Amazon S3 Cloud Storage
  • etcd distributed storage
Install as dependency
go get github.com/rovergulf/storage

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewEtcdStorage

func NewEtcdStorage(opts EtcdOptions) (*etcdStorage, error)

Types

type AWSStorage

type AWSStorage struct {
	Bucket     string
	Client     *s3.S3
	Downloader *s3manager.Downloader
	Prefix     string
	Uploader   *s3manager.Uploader
	SSE        string
}

func NewAWSStorage

func NewAWSStorage(bucket string, prefix string, region string, endpoint string, sse string) (*AWSStorage, error)

func (*AWSStorage) DeleteObject

func (s *AWSStorage) DeleteObject(key string) error

func (*AWSStorage) GetObject

func (s *AWSStorage) GetObject(key string) (Object, error)

func (*AWSStorage) ListObjects

func (s *AWSStorage) ListObjects(prefix string) ([]Object, error)

func (*AWSStorage) PutObject

func (s *AWSStorage) PutObject(key string, data []byte) error

type Backend

type Backend interface {
	ListObjects(prefix string) ([]Object, error)
	GetObject(key string) (Object, error)
	PutObject(key string, data []byte) error
	DeleteObject(key string) error
}

Backend is a generic interface for storage backends

type DirStorage

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

func NewDirStorage

func NewDirStorage(rootDir string) (*DirStorage, error)

func (*DirStorage) DeleteObject

func (s *DirStorage) DeleteObject(key string) error

func (*DirStorage) GetObject

func (s *DirStorage) GetObject(key string) (Object, error)

func (*DirStorage) ListObjects

func (s *DirStorage) ListObjects(prefix string) ([]Object, error)

func (*DirStorage) PutObject

func (s *DirStorage) PutObject(key string, data []byte) error

type EtcdOptions

type EtcdOptions struct {
	Logger *zap.SugaredLogger
	Config *clientv3.Config
}

type GCPStorage

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

func NewGCPStorage

func NewGCPStorage(bucket string, prefix string) (*GCPStorage, error)

func (*GCPStorage) DeleteObject

func (s *GCPStorage) DeleteObject(key string) error

DeleteObject removes an object from Google Cloud Storage bucket, at prefix

func (*GCPStorage) GetObject

func (s *GCPStorage) GetObject(key string) (Object, error)

func (*GCPStorage) ListObjects

func (s *GCPStorage) ListObjects(prefix string) ([]Object, error)

func (*GCPStorage) PutObject

func (s *GCPStorage) PutObject(key string, content []byte) error

PutObject uploads an object to Google Cloud Storage bucket, at prefix

type Metadata

type Metadata struct {
	Name    string
	Version string
}

Metadata represents the meta information of the object includes object name , object version , etc...

type Object

type Object struct {
	Meta         Metadata
	Path         string
	Data         []byte
	LastModified time.Time
}

Object is a generic representation of a storage object

func (Object) HasExtension

func (object Object) HasExtension(extension string) bool

HasExtension determines whether or not an object contains a file extension

type ObjectSliceDiff

type ObjectSliceDiff struct {
	Change  bool
	Removed []Object
	Added   []Object
	Updated []Object
}

ObjectSliceDiff provides information on what has changed since last calling ListObjects

func GetObjectSliceDiff

func GetObjectSliceDiff(prev []Object, curr []Object, timestampTolerance time.Duration) ObjectSliceDiff

GetObjectSliceDiff takes two objects slices and returns an ObjectSliceDiff

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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