s3backend

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const BlockSize = 1024 * 1024 // 1MB per block

Variables

View Source
var (
	ErrChunkSizeMisMatch = errors.New("chunk size is not matching with data size")
)

Functions

This section is empty.

Types

type Block added in v0.0.2

type Block struct {
	gorm.Model
	Data []byte `gorm:"column=data"`
}

type Bucket

type Bucket struct {
	gorm.Model
	Bucket string `gorm:"column=bucket"`
}

type Content

type Content struct {
	gorm.Model
	Bucket   string `gorm:"column=bucket"`
	Key      string `gorm:"column=key"`
	Size     int64  `gorm:"column=size"`
	Sha256   string `gorm:"column=sha256"`
	MD5      string `gorm:"column=md5"`
	ObjectID uint   `gorm:"object_id"`
}

type Database added in v0.0.2

type Database struct {
	*gorm.DB
}

func (*Database) DBCreateBucketByName added in v0.0.2

func (d *Database) DBCreateBucketByName(ctx context.Context, name string) (Bucket, error)

func (*Database) DBCreateObject added in v0.0.2

func (d *Database) DBCreateObject(blockData []byte, blockNum int32) (*Object, error)

func (*Database) DBCreateObjectWithTx added in v0.0.2

func (d *Database) DBCreateObjectWithTx(tx *gorm.DB, blockData []byte, blockNum int32) (*Object, error)

func (*Database) DBCreateOrUpdateContent added in v0.0.2

func (d *Database) DBCreateOrUpdateContent(content *Content) error

func (*Database) DBCreateOrUpdateContentWithTx added in v0.0.2

func (d *Database) DBCreateOrUpdateContentWithTx(tx *gorm.DB, content *Content) error

func (*Database) DBDeleteAllBlockInObj added in v0.0.2

func (d *Database) DBDeleteAllBlockInObj(objID uint) error

func (*Database) DBDeleteAllBlockInObjWithTx added in v0.0.2

func (d *Database) DBDeleteAllBlockInObjWithTx(tx *gorm.DB, objID uint) error

func (*Database) DBGetBucketByName added in v0.0.2

func (d *Database) DBGetBucketByName(ctx context.Context, name string) (Bucket, error)

func (*Database) DBGetContent added in v0.0.2

func (d *Database) DBGetContent(bucket, key string) (*Content, error)

func (*Database) DBGetContentWithTx added in v0.0.2

func (d *Database) DBGetContentWithTx(tx *gorm.DB, bucket, key string) (*Content, error)

func (*Database) DBGetObjectByIDWithTx added in v0.0.2

func (d *Database) DBGetObjectByIDWithTx(tx *gorm.DB, objID uint) (*Object, error)

func (*Database) DBSaveChunk added in v0.0.2

func (d *Database) DBSaveChunk(tx *gorm.DB, chunk *s3pb.PutObjectChunk) ([]*s3pb.Block, error)

type Object added in v0.0.2

type Object struct {
	gorm.Model
	BlockNums int32  `gorm:"column=block_nums"`
	Blocks    []byte `gorm:"column=blocks"`
}

type S3Backend

type S3Backend struct {
	*Database
}

func NewS3Backend

func NewS3Backend(dbPath string) *S3Backend

func NewS3BackendMysql

func NewS3BackendMysql(cfg mysql.Config) *S3Backend

func (*S3Backend) CreateBucket

func (s *S3Backend) CreateBucket(ctx context.Context, request *pb.CreateBucketRequest) (*pb.CreateBucketResponse, error)

func (*S3Backend) DeleteObject

func (s *S3Backend) DeleteObject(ctx context.Context, request *pb.DeleteObjectRequest) (*pb.DeleteObjectResponse, error)

func (*S3Backend) GetBucket

func (s *S3Backend) GetBucket(ctx context.Context, request *pb.GetBucketRequest) (*pb.GetBucketResponse, error)

func (*S3Backend) GetObject

func (s *S3Backend) GetObject(request *pb.GetObjectRequest, server pb.Backend_GetObjectServer) error

func (*S3Backend) HeadObject added in v0.0.2

func (s *S3Backend) HeadObject(ctx context.Context, request *pb.GetObjectRequest) (*pb.HeadObjectResponse, error)

func (*S3Backend) ListBuckets

func (s *S3Backend) ListBuckets(ctx context.Context, request *pb.ListBucketsRequest) (*pb.ListBucketsResponse, error)

func (*S3Backend) PutObject

func (s *S3Backend) PutObject(server pb.Backend_PutObjectServer) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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