driver

package
v0.0.0-...-2bcf714 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package driver defines a set of interfaces that the blob package uses to interact with the underlying blob services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket interface {
	// CreateUserArea setups a new area with the given id
	//
	// only local filesystem need to support this
	// object storage based providers use object whole path as its key, so there is no need to pre create or setup its area
	CreateArea(ctx context.Context, area string, groups []string) error

	// Attributes returns attributes for the blob. If the specified object does
	// not exist, Attributes must return an error for which ErrorCode returns
	// gcerrors.NotFound.
	// The portable type will not modify the returned Attributes.
	Attributes(ctx context.Context, key string, isUID bool) (*ObjectAttrs, error)

	// NewRangeReader returns a Reader that reads part of an object, reading at
	// most length bytes starting at the given offset. If length is 0, it will read
	// only the metadata. If length is negative, it will read till the end of the
	// object. If the specified object does not exist, NewRangeReader must return
	// an error whose BlobError method returns NotFound.
	NewRangeReader(ctx context.Context, key string, offset, length int64, exactName bool) (Reader, error)

	// NewTypedWriter returns Writer that writes to an object associated with key.
	//
	// A new object will be created unless an object with this key already exists.
	// Otherwise any previous object with the same name will be replaced.
	// The object may not be available (and any previous object will remain)
	// until Close has been called.
	//
	// contentType sets the MIME type of the object to be written. It must not be
	// empty.
	//
	// The caller must call Close on the returned Writer when done writing.
	NewTypedWriter(ctx context.Context, key string, contentType string, opt *WriterOptions) (Writer, error)

	// Move moves the object associated with key from keySrc to KeyDst
	Move(ctx context.Context, keySrc string, keyDst string) error

	// Delete deletes the object associated with key.
	Delete(ctx context.Context, key string) error
}

Bucket provides read, write and delete operations on objects within it on the blob service.

type Error

type Error interface {
	error
	BlobError() ErrorKind
}

Error is an interface that may be implemented by an error returned by a driver to indicate the kind of failure. If an error does not have the BlobError method, then it is assumed to be GenericError.

type ErrorKind

type ErrorKind int

ErrorKind is a code to indicate the kind of failure.

const (
	GenericError ErrorKind = iota
	NotFound
)

type ObjectAttrs

type ObjectAttrs struct {
	// Size is the size of the object in bytes.
	Size int64
	// ContentType is the MIME type of the blob object. It must not be empty.
	ContentType string
	// ModTime is the modified time of the blob object. Will be time.Time zero value if unknown.
	ModTime time.Time

	// Object metadata
	Name     string
	Fields   map[string]string
	Revision int

	Id    int
	Extra string // platform specific
}

ObjectAttrs contains metadata of an object.

type Reader

type Reader interface {
	io.ReadCloser

	// Attrs returns the object's metadata. It may return a different pointer each
	// time, but it must return the exact same values each time it is called. The
	// caller must not modify any fields in the returned ObjectAttrs.
	Attrs() *ObjectAttrs
}

Reader reads an object from the blob.

type Writer

type Writer interface {
	io.WriteCloser
}

Writer writes an object to the blob.

type WriterOptions

type WriterOptions struct {
	// BufferSize changes the default size in byte of the maximum part Writer can
	// write in a single request, if supported. Larger objects will be split into
	// multiple requests.
	BufferSize int

	// Tiddler metadata
	Metadata map[string]string
	Revision int
	// Extra options for platform specific implementations
	Id    int
	Name  string
	Extra map[string]string
	// Size of the text segment
	ContentSize int
}

WriterOptions controls behaviors of Writer.

Jump to

Keyboard shortcuts

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