go-cloud: github.com/google/go-cloud/blob/driver Index | Files

package driver

import "github.com/google/go-cloud/blob/driver"

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

Index

Package Files

driver.go

type Bucket Uses

type Bucket interface {
    // 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) (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)

    // Delete deletes the object associated with key. If the specified object does
    // not exist, NewRangeReader must return an error whose BlobError method
    // returns NotFound.
    Delete(ctx context.Context, key string) error
}

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

type Error Uses

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 Uses

type ErrorKind int

ErrorKind is a code to indicate the kind of failure.

const (
    GenericError ErrorKind = iota
    NotFound
)

type ObjectAttrs Uses

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
}

ObjectAttrs contains metadata of an object.

type Reader Uses

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 Uses

type Writer interface {
    io.WriteCloser
}

Writer writes an object to the blob.

type WriterOptions Uses

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
}

WriterOptions controls behaviors of Writer.

Package driver imports 3 packages (graph) and is imported by 4 packages. Updated 2018-08-14. Refresh now. Tools for package owners.