storage_service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() (sdk.StorageService, error)

New creates a new default StorageService

func NewWithStorageDriver

func NewWithStorageDriver(driver StorageDriver) (sdk.StorageService, error)

NewWithStorageDriver creates a new StorageService with the given StorageDriver primarily used for mock testing

Types

type DefaultStorageDriver

type DefaultStorageDriver struct {
}

DefaultStorageDriver - The Storage Driver to be used when creating a new Local Storage Plugin using the New() method

func (*DefaultStorageDriver) DeleteFile

func (s *DefaultStorageDriver) DeleteFile(file string) error

DeleteFile - Deletes the file at the given path

func (*DefaultStorageDriver) EnsureDirExists

func (s *DefaultStorageDriver) EnsureDirExists(dir string) error

EnsureDirExists - Recursively creates directories for the given path

func (*DefaultStorageDriver) ExistsOrFail

func (s *DefaultStorageDriver) ExistsOrFail(path string) error

ExistsOrFail - Returns an error if the provided path doesn't exist in the file system

func (*DefaultStorageDriver) ReadFile

func (s *DefaultStorageDriver) ReadFile(file string) ([]byte, error)

ReadFile - Reads from the given path and returns the byte array

func (*DefaultStorageDriver) WriteFile

func (s *DefaultStorageDriver) WriteFile(file string, contents []byte, fileMode os.FileMode) error

WriteFile - Writes the given byte array to the given path

type LocalStorageService

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

LocalStorageService - The Nitric Storage Plugin for local development work Primarily used as part of the nitric run CLI function

func (*LocalStorageService) Delete

func (s *LocalStorageService) Delete(bucket string, key string) error

Delete - deletes an item from Storage

func (*LocalStorageService) Read

func (s *LocalStorageService) Read(bucket string, key string) ([]byte, error)

Read - reads an item from Storage

func (*LocalStorageService) Write

func (s *LocalStorageService) Write(bucket string, key string, payload []byte) error

Write - will create a new item or overwrite an existing item in storage

type StorageDriver

type StorageDriver interface {
	EnsureDirExists(string) error
	ExistsOrFail(string) error
	WriteFile(string, []byte, os.FileMode) error
	ReadFile(string) ([]byte, error)
	DeleteFile(string) error
}

StorageDriver - The interface used by the LocalStorage plugin to write/read files from the local file system

Jump to

Keyboard shortcuts

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