storage

package
v0.0.0-...-9e2eb7f Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: GPL-3.0 Imports: 12 Imported by: 2

Documentation

Overview

Package storage provides interface for working with different storage's like local FS and Amazon S3.

Index

Constants

This section is empty.

Variables

View Source
var Log = logrus.New()

Log implement Logrus logger for debug logging.

Functions

func GetInsecureRandString

func GetInsecureRandString(n int) string

func IsAwsContextCanceled

func IsAwsContextCanceled(err error) bool

func IsErrNotExist

func IsErrNotExist(err error) bool

func IsErrPermission

func IsErrPermission(err error) bool

func StrongEtag

func StrongEtag(s *string) *string

StrongEtag remove "W/" prefix from ETag. In some cases S3 return ETag with "W/" prefix which mean that it not strong ETag. For easier compare we remove this prefix.

func ToPtr

func ToPtr[K any](val K) *K

func ToValue

func ToValue[K any](val *K) K

Types

type ErrHandlingMask

type ErrHandlingMask uint8

ErrHandlingMask is is a bitmask for storing error handling settings.

const (
	HandleErrNotExist ErrHandlingMask = 1 << iota
	HandleErrPermission
	HandleErrOther = 64
)

func (*ErrHandlingMask) Add

func (f *ErrHandlingMask) Add(flag ErrHandlingMask)

Add the flag to the bitmask.

func (ErrHandlingMask) Has

func (f ErrHandlingMask) Has(flag ErrHandlingMask) bool

Has checks if the flag is set in the bitmask.

type Object

type Object struct {
	Key                  *string                 `json:"-"`
	ETag                 *string                 `json:"e_tag"`
	Mtime                *time.Time              `json:"mtime"`
	Content              *[]byte                 `json:"-"`
	ContentStream        io.ReadCloser           `json:"-"`
	ContentLength        *int64                  `json:"-"`
	ContentType          *string                 `json:"content_type"`
	ContentDisposition   *string                 `json:"content_disposition"`
	ContentEncoding      *string                 `json:"content_encoding"`
	ContentLanguage      *string                 `json:"content_language"`
	Metadata             map[string]*string      `json:"metadata"`
	ACL                  *string                 `json:"acl"`
	CacheControl         *string                 `json:"cache_control"`
	VersionId            *string                 `json:"version_id"`
	IsLatest             *bool                   `json:"-"`
	StorageClass         *string                 `json:"storage_class"`
	AccessControlPolicy  *s3.AccessControlPolicy `json:"access_control_policy"`
	ServerSideEncryption *string                 `json:"server_side_encryption"`
}

Object contain content and metadata of S3 object.

type Storage

type Storage interface {
	WithContext(ctx context.Context)
	WithRateLimit(limit int) error
	List(ch chan<- *Object) error
	PutObject(object *Object) error
	GetObjectContent(obj *Object) error
	GetObjectMeta(obj *Object) error
	GetObjectACL(obj *Object) error
	DeleteObject(obj *Object) error
}

Storage interface.

type Type

type Type int

Type of Storage.

const (
	TypeS3 Type = iota + 1
	TypeS3Versioned
	TypeFS
	TypeS3Stream
	TypeSwift
)

Storage types.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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