datastorage

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureBaseDir

func EnsureBaseDir(fpath string) error

Types

type Datastorer

type Datastorer interface {
	Save([]byte) error
	Load() ([]byte, error)
}

Datastorer reads and writes data to an object.

type GCPStorage

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

GCPStorage represents a Google Cloud Storage object.

func NewGCPStorage

func NewGCPStorage(bucket string, object string) *GCPStorage

NewGCPStorage returns a Google Cloud storage item given a bucket and an object path.

func (*GCPStorage) Load

func (s *GCPStorage) Load() ([]byte, error)

Load downloads an object from a bucket and returns an error if it cannot be read.

func (*GCPStorage) Save

func (s *GCPStorage) Save(b []byte) error

Save uploads an object to a bucket and returns an error if it cannot be written.

type LocalStorage

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

LocalStorage represents a file on the filesytem.

func NewLocalStorage

func NewLocalStorage(path string) *LocalStorage

NewLocalStorage returns a local storage object given a file path.

func (*LocalStorage) Load

func (s *LocalStorage) Load() ([]byte, error)

Load returns a file contents from the filesystem.

func (*LocalStorage) Save

func (s *LocalStorage) Save(b []byte) error

Save writes a file to the filesystem and returns an error if one occurs.

type S3Storage

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

GCPStorage represents a S3 Storage object.

func NewS3Storage

func NewS3Storage(bucket string, object string, region string) *S3Storage

NewGCPStorage returns a S3 storage item given a bucket and an object path.

func (*S3Storage) Load

func (s *S3Storage) Load() ([]byte, error)

Load downloads an object from a bucket and returns an error if it cannot be read.

func (*S3Storage) Save

func (s *S3Storage) Save(b []byte) error

Save uploads an object to a bucket and returns an error if it cannot be written.

type Storage

type Storage struct {
	Site *model.Site
	// contains filtered or unexported fields
}

Storage represents a writable and readable object.

func New

func New(ds Datastorer, site *model.Site) (*Storage, error)

New returns a writable and readable site object. Returns an error if the object cannot be initially read.

func (*Storage) Load

func (s *Storage) Load() error

Load reads the site object from the data storage and returns an error if it cannot be read.

func (*Storage) Save

func (s *Storage) Save() error

Save writes the site object to the data storage and returns an error if it cannot be written.

Jump to

Keyboard shortcuts

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