blob

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 15 Imported by: 4

Documentation

Overview

Package blob is used to read/write data from blob stores.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExist = errors.New("not exist")

ErrNotExist is the error returned when attempting to query blob data that does not exist.

View Source
var ErrStopIterating = errors.New("stop iterating")

ErrStopIterating is the error used to stop the iterator from continuing.

Functions

This section is empty.

Types

type Blob added in v1.2.0

type Blob struct {
	Key     string
	Size    int64
	ModTime time.Time
}

The Blob type contains metadata on an item in the blob store.

type Bucket

type Bucket struct {
	// contains filtered or unexported fields
}

The Bucket type represents a bucket of blob data that can be arbitrarily written to and read using a key.

func OpenBucket

func OpenBucket(ctx context.Context, dsn string) (*Bucket, error)

OpenBucket opens the bucket identified by the URL given.

func (*Bucket) Close

func (bkt *Bucket) Close() error

Close the connection to the bucket.

func (*Bucket) Delete

func (bkt *Bucket) Delete(ctx context.Context, key string) error

Delete deletes the blob stored at key. Returns ErrNotExist if the key does not exist.

func (*Bucket) Iterate added in v1.2.0

func (bkt *Bucket) Iterate(ctx context.Context, fn Iterator) error

Iterate over the contents of the bucket, invoking fn for each item, excluding any directories. Iteration can be cancelled via the provided context or by fn returning ErrStopIterating or any other non-nil error.

func (*Bucket) NewRangeReader

func (bkt *Bucket) NewRangeReader(ctx context.Context, key string, offset, length int64) (*Reader, error)

NewRangeReader returns a Reader to read content from the blob stored at key from one offset to a certain number of bytes.

func (*Bucket) NewReader

func (bkt *Bucket) NewReader(ctx context.Context, key string) (*Reader, error)

NewReader returns a Reader to read content from the blob stored at key.

func (*Bucket) NewWriter

func (bkt *Bucket) NewWriter(ctx context.Context, key string) (*Writer, error)

NewWriter returns a Writer that writes to the blob stored at key.

func (*Bucket) Ping

func (bkt *Bucket) Ping() error

Ping is a basic check to ensure the connection to the bucket is healthy.

type Iterator added in v1.2.0

type Iterator func(ctx context.Context, item Blob) error

Iterator is a function used on a call to Bucket.Iterate that is invoked for each item in the bucket.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

The Reader type is able to read blob data for a desired key. It is instrumented to write spans to the tracer when blob data is read.

func (*Reader) Close

func (r *Reader) Close() error

Close the blob reader, this will finish the traced span.

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

Read implements io.Reader (https://golang.org/pkg/io/#Reader).

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

The Writer type is able to write blob data for a desired key. It is instrumented to write spans to the tracer when blob data is written.

func (*Writer) Close

func (w *Writer) Close() error

Close the blob writer.

func (*Writer) ReadFrom

func (w *Writer) ReadFrom(r io.Reader) (int64, error)

ReadFrom reads from r and writes to w until EOF or error. The return value is the number of bytes read from r.

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Write the bytes in p to the blob store.

Jump to

Keyboard shortcuts

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