layer

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const PathSeparator = string(os.PathSeparator)

PathSeparator is a path components separator string.

Variables

View Source
var (
	// ErrObjectExists is returned on attempts to create already existing object.
	ErrObjectExists = errors.New("object exists")
	// ErrObjectNotExists is returned on attempts to work with non-existing object.
	ErrObjectNotExists = errors.New("object not exists")
	// ErrBucketAlreadyExists is returned on attempts to create already existing bucket.
	ErrBucketAlreadyExists = errors.New("bucket exists")
	// ErrBucketNotFound is returned on attempts to get not existing bucket.
	ErrBucketNotFound = errors.New("bucket not found")
)

Functions

func NameFromString

func NameFromString(name string) (string, string)

NameFromString splits name into base file name and directory path.

Types

type BucketInfo

type BucketInfo struct {
	Name    string
	CID     *cid.ID
	Owner   *owner.ID
	Created time.Time
}

BucketInfo stores basic bucket data.

type Client

type Client interface {
	NeoFS

	ListBuckets(ctx context.Context) ([]*BucketInfo, error)
	GetBucketInfo(ctx context.Context, name string) (*BucketInfo, error)
	CreateBucket(ctx context.Context, p *CreateBucketParams) (*cid.ID, error)
	DeleteBucket(ctx context.Context, p *DeleteBucketParams) error

	GetObject(ctx context.Context, p *GetObjectParams) error
	GetObjectInfo(ctx context.Context, bucketName, objectName string) (*ObjectInfo, error)

	PutObject(ctx context.Context, p *PutObjectParams) (*ObjectInfo, error)

	CopyObject(ctx context.Context, p *CopyObjectParams) (*ObjectInfo, error)

	ListObjects(ctx context.Context, p *ListObjectsParams) (*ListObjectsInfo, error)
	ListObjectVersions(ctx context.Context, p *ListObjectVersionsParams) (*ListObjectVersionsInfo, error)

	DeleteObject(ctx context.Context, bucket, object string) error
	DeleteObjects(ctx context.Context, bucket string, objects []string) []error
}

Client provides S3 API client interface.

func NewLayer

func NewLayer(log *zap.Logger, conns pool.Pool) Client

NewLayer creates instance of layer. It checks credentials and establishes gRPC connection with node.

type CopyObjectParams

type CopyObjectParams struct {
	SrcBucket string
	DstBucket string
	SrcObject string
	DstObject string
	SrcSize   int64
	Header    map[string]string
}

CopyObjectParams stores object copy request parameters.

type CreateBucketParams added in v0.16.0

type CreateBucketParams struct {
	Name   string
	ACL    uint32
	Policy *netmap.PlacementPolicy
}

CreateBucketParams stores bucket create request parameters.

type DeleteBucketParams added in v0.16.0

type DeleteBucketParams struct {
	Name string
}

DeleteBucketParams stores delete bucket request parameters.

type DeletedObjectInfo added in v0.16.0

type DeletedObjectInfo struct {
	Owner        *owner.ID
	Key          string
	VersionID    string
	IsLatest     bool
	LastModified string
}

DeletedObjectInfo stores info about deleted versions of objects.

type GetObjectParams

type GetObjectParams struct {
	Range  *RangeParams
	Bucket string
	Object string
	Offset int64
	Length int64
	Writer io.Writer
}

GetObjectParams stores object get request parameters.

type ListObjectVersionsInfo added in v0.16.0

type ListObjectVersionsInfo struct {
	CommonPrefixes      []*string
	IsTruncated         bool
	KeyMarker           string
	NextKeyMarker       string
	NextVersionIDMarker string
	Version             []*ObjectVersionInfo
	DeleteMarker        []*DeletedObjectInfo
	VersionIDMarker     string
}

ListObjectVersionsInfo stores info and list of objects' versions.

type ListObjectVersionsParams added in v0.16.0

type ListObjectVersionsParams struct {
	Bucket          string
	Delimiter       string
	KeyMarker       string
	MaxKeys         int
	Prefix          string
	VersionIDMarker string
	Encode          string
}

ListObjectVersionsParams stores list objects versions parameters.

type ListObjectsInfo

type ListObjectsInfo struct {
	// Indicates whether the returned list objects response is truncated. A
	// value of true indicates that the list was truncated. The list can be truncated
	// if the number of objects exceeds the limit allowed or specified
	// by max keys.
	IsTruncated bool

	// When response is truncated (the IsTruncated element value in the response
	// is true), you can use the key name in this field as marker in the subsequent
	// request to get next set of objects.
	//
	// NOTE: This element is returned only if you have delimiter request parameter
	// specified.
	ContinuationToken     string
	NextContinuationToken string

	// When response is truncated (the IsTruncated element value in the response is true),
	// you can use the key name in this field as marker in the subsequent request to get next set of objects.
	NextMarker string

	// List of objects info for this request.
	Objects []*ObjectInfo

	// List of prefixes for this request.
	Prefixes []string
}

ListObjectsInfo - container for list objects.

type ListObjectsParams

type ListObjectsParams struct {
	Bucket    string
	Prefix    string
	Token     string
	Delimiter string
	MaxKeys   int
	Marker    string
	Version   int
}

ListObjectsParams represents object listing request parameters.

type NeoFS

type NeoFS interface {
	Get(ctx context.Context, address *object.Address) (*object.Object, error)
}

NeoFS provides basic NeoFS interface.

type ObjectInfo

type ObjectInfo struct {
	Bucket      string
	Name        string
	Size        int64
	ContentType string
	Created     time.Time
	HashSum     string
	Owner       *owner.ID
	Headers     map[string]string
	// contains filtered or unexported fields
}

ObjectInfo holds S3 object data.

func (*ObjectInfo) ID

func (o *ObjectInfo) ID() *object.ID

ID returns object ID from ObjectInfo.

func (*ObjectInfo) IsDir

func (o *ObjectInfo) IsDir() bool

IsDir allows to check if object is a directory.

type ObjectVersionInfo added in v0.16.0

type ObjectVersionInfo struct {
	Object    *ObjectInfo
	IsLatest  bool
	VersionID string
}

ObjectVersionInfo stores info about objects versions.

type Params

type Params struct {
	Pool    pool.Pool
	Logger  *zap.Logger
	Timeout time.Duration
	Key     *ecdsa.PrivateKey
}

Params stores basic API parameters.

type PutObjectParams

type PutObjectParams struct {
	Bucket string
	Object string
	Size   int64
	Reader io.Reader
	Header map[string]string
}

PutObjectParams stores object put request parameters.

type RangeParams added in v0.16.0

type RangeParams struct {
	Start uint64
	End   uint64
}

RangeParams stores range header request parameters.

Jump to

Keyboard shortcuts

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